Thread Subject: save file

Subject: save file

From: Nico zanette

Date: 22 Jul, 2009 10:42:03

Message: 1 of 11

hi! i have this piece of code:

for n = 1 : n_SEZIONE
    
    SLICE_NUMBER = R * n;
    
    fid = fopen ('C:\Users\hp\Desktop\TESI\Modello.Seno\Phantom.1\sliceHm.txt', 'wt');
    for J_X_FOR = 1 : DISCRETIZZAZIONE_X
        for K_X_FOR = 1 : DISCRETIZZAZIONE_Z
            SLICE_H(K_X_FOR, J_X_FOR) = MATRICE_3D_PROPRIETA(J_X_FOR, SLICE_NUMBER, K_X_FOR);
            fprintf (fid,'%1.1f\n',SLICE_H(K_X_FOR, J_X_FOR));
        end
    end
    fclose(fid);

The problem is: i want to create a sliceHm.txt for every iteration of the for cylcle and to save it like SliceHm(SLICE_NUMBER).txt.
How can i do?

Thanks

Subject: save file

From: us

Date: 22 Jul, 2009 10:57:03

Message: 2 of 11

"Nico zanette" <zannakill@hotmail.com> wrote in message <h46qdr$1u0$1@fred.mathworks.com>...
> The problem is: i want to create a sliceHm.txt for every iteration of the for cylcle and to save it like SliceHm(SLICE_NUMBER).txt.
> How can i do?
>
> Thanks

a hint:

http://matlabwiki.mathworks.com/MATLAB_FAQ#How_can_I_process_a_sequence_of_files.3F

us

Subject: save file

From: Shanmugam Kannappan

Date: 22 Jul, 2009 11:04:05

Message: 3 of 11

"Nico zanette" <zannakill@hotmail.com> wrote in message <h46qdr$1u0$1@fred.mathworks.com>...
> hi! i have this piece of code:
>
> for n = 1 : n_SEZIONE
>
> SLICE_NUMBER = R * n;
>
> fid = fopen ('C:\Users\hp\Desktop\TESI\Modello.Seno\Phantom.1\sliceHm.txt', 'wt');
> for J_X_FOR = 1 : DISCRETIZZAZIONE_X
> for K_X_FOR = 1 : DISCRETIZZAZIONE_Z
> SLICE_H(K_X_FOR, J_X_FOR) = MATRICE_3D_PROPRIETA(J_X_FOR, SLICE_NUMBER, K_X_FOR);
> fprintf (fid,'%1.1f\n',SLICE_H(K_X_FOR, J_X_FOR));
> end
> end
> fclose(fid);
>
> The problem is: i want to create a sliceHm.txt for every iteration of the for cylcle and to save it like SliceHm(SLICE_NUMBER).txt.
> How can i do?
>
> Thanks
Hi!
you mean to say like,want to save it in different file(total number of file will be DISCRETIZZAZIONE_X * DISCRETIZZAZIONE_Z)
If so
put your fopen command inside the llop & modify the parameters & logic so as to open
 files in write mode & close the files once written...
I am not sure about its reliability,if needed thats the way you can do.....

Shan.......

Subject: save file

From: Nico zanette

Date: 22 Jul, 2009 11:13:06

Message: 4 of 11

"us " <us@neurol.unizh.ch> wrote in message <h46r9v$l2l$1@fred.mathworks.com>...
> "Nico zanette" <zannakill@hotmail.com> wrote in message <h46qdr$1u0$1@fred.mathworks.com>...
> > The problem is: i want to create a sliceHm.txt for every iteration of the for cylcle and to save it like SliceHm(SLICE_NUMBER).txt.
> > How can i do?
> >
> > Thanks
>
> a hint:
>
> http://matlabwiki.mathworks.com/MATLAB_FAQ#How_can_I_process_a_sequence_of_files.3F
>
> us

Thanks us! I'll take a look to it.

Subject: save file

From: Nico zanette

Date: 22 Jul, 2009 11:18:07

Message: 5 of 11

"Shanmugam Kannappan" <shanmugambe@gmail.com> wrote in message <h46rn5$fdn$1@fred.mathworks.com>...
> "Nico zanette" <zannakill@hotmail.com> wrote in message <h46qdr$1u0$1@fred.mathworks.com>...
> > hi! i have this piece of code:
> >
> > for n = 1 : n_SEZIONE
> >
> > SLICE_NUMBER = R * n;
> >
> > fid = fopen ('C:\Users\hp\Desktop\TESI\Modello.Seno\Phantom.1\sliceHm.txt', 'wt');
> > for J_X_FOR = 1 : DISCRETIZZAZIONE_X
> > for K_X_FOR = 1 : DISCRETIZZAZIONE_Z
> > SLICE_H(K_X_FOR, J_X_FOR) = MATRICE_3D_PROPRIETA(J_X_FOR, SLICE_NUMBER, K_X_FOR);
> > fprintf (fid,'%1.1f\n',SLICE_H(K_X_FOR, J_X_FOR));
> > end
> > end
> > fclose(fid);
> >
> > The problem is: i want to create a sliceHm.txt for every iteration of the for cylcle and to save it like SliceHm(SLICE_NUMBER).txt.
> > How can i do?
> >
> > Thanks
> Hi!
> you mean to say like,want to save it in different file(total number of file will be DISCRETIZZAZIONE_X * DISCRETIZZAZIONE_Z)
> If so
> put your fopen command inside the llop & modify the parameters & logic so as to open
> files in write mode & close the files once written...
> I am not sure about its reliability,if needed thats the way you can do.....
>
> Shan.......

Hi

Oh no... the number of files i want to save is n_SEZIONE and i want to save them as
sliceHm(SLICE_NUMBER)...

I mean, for every n there is a SLICE_NUMBER and i want to put this number in the file name.

Thanks

Subject: save file

From: Caroline From France

Date: 22 Jul, 2009 11:28:09

Message: 6 of 11

"Nico zanette" <zannakill@hotmail.com> wrote in message <h46shf$80s$1@fred.mathworks.com>...
>
> Oh no... the number of files i want to save is n_SEZIONE and i want to save them as
> sliceHm(SLICE_NUMBER)...
>
> I mean, for every n there is a SLICE_NUMBER and i want to put this number in the file name.
>
> Thanks

Hi

Did you ever read the link posted by us ?
It gives exactly what you want.

http://matlabwiki.mathworks.com/MATLAB_FAQ#How_can_I_process_a_sequence_of_files.3F

Caroline

Subject: save file

From: Shanmugam Kannappan

Date: 22 Jul, 2009 11:30:09

Message: 7 of 11

"Nico zanette" <zannakill@hotmail.com> wrote in message <h46shf$80s$1@fred.mathworks.com>...
> "Shanmugam Kannappan" <shanmugambe@gmail.com> wrote in message <h46rn5$fdn$1@fred.mathworks.com>...
> > "Nico zanette" <zannakill@hotmail.com> wrote in message <h46qdr$1u0$1@fred.mathworks.com>...
> > > hi! i have this piece of code:
> > >
> > > for n = 1 : n_SEZIONE
> > >
> > > SLICE_NUMBER = R * n;
> > >
> > > fid = fopen ('C:\Users\hp\Desktop\TESI\Modello.Seno\Phantom.1\sliceHm.txt', 'wt');
> > > for J_X_FOR = 1 : DISCRETIZZAZIONE_X
> > > for K_X_FOR = 1 : DISCRETIZZAZIONE_Z
> > > SLICE_H(K_X_FOR, J_X_FOR) = MATRICE_3D_PROPRIETA(J_X_FOR, SLICE_NUMBER, K_X_FOR);
> > > fprintf (fid,'%1.1f\n',SLICE_H(K_X_FOR, J_X_FOR));
> > > end
> > > end
> > > fclose(fid);
> > >
> > > The problem is: i want to create a sliceHm.txt for every iteration of the for cylcle and to save it like SliceHm(SLICE_NUMBER).txt.
> > > How can i do?
> > >
> > > Thanks
> > Hi!
> > you mean to say like,want to save it in different file(total number of file will be DISCRETIZZAZIONE_X * DISCRETIZZAZIONE_Z)
> > If so
> > put your fopen command inside the llop & modify the parameters & logic so as to open
> > files in write mode & close the files once written...
> > I am not sure about its reliability,if needed thats the way you can do.....
> >
> > Shan.......
>
> Hi
>
> Oh no... the number of files i want to save is n_SEZIONE and i want to save them as
> sliceHm(SLICE_NUMBER)...
>
> I mean, for every n there is a SLICE_NUMBER and i want to put this number in the file name.
>
> Thanks
Hi,
Oh...O.K.....
Try something like this...
fid = fopen( ['C:\Users\hp\Desktop\TESI\Modello.Seno\Phantom.1\sliceHm' num2str(SLICE_NUMBER) '.txt'],'wt');
Shan......

Subject: save file

From: Nico zanette

Date: 22 Jul, 2009 12:23:03

Message: 8 of 11

"Shanmugam Kannappan" <shanmugambe@gmail.com> wrote in message <h46t81$mei$1@fred.mathworks.com>...
> "Nico zanette" <zannakill@hotmail.com> wrote in message <h46shf$80s$1@fred.mathworks.com>...
> > "Shanmugam Kannappan" <shanmugambe@gmail.com> wrote in message <h46rn5$fdn$1@fred.mathworks.com>...
> > > "Nico zanette" <zannakill@hotmail.com> wrote in message <h46qdr$1u0$1@fred.mathworks.com>...
> > > > hi! i have this piece of code:
> > > >
> > > > for n = 1 : n_SEZIONE
> > > >
> > > > SLICE_NUMBER = R * n;
> > > >
> > > > fid = fopen ('C:\Users\hp\Desktop\TESI\Modello.Seno\Phantom.1\sliceHm.txt', 'wt');
> > > > for J_X_FOR = 1 : DISCRETIZZAZIONE_X
> > > > for K_X_FOR = 1 : DISCRETIZZAZIONE_Z
> > > > SLICE_H(K_X_FOR, J_X_FOR) = MATRICE_3D_PROPRIETA(J_X_FOR, SLICE_NUMBER, K_X_FOR);
> > > > fprintf (fid,'%1.1f\n',SLICE_H(K_X_FOR, J_X_FOR));
> > > > end
> > > > end
> > > > fclose(fid);
> > > >
> > > > The problem is: i want to create a sliceHm.txt for every iteration of the for cylcle and to save it like SliceHm(SLICE_NUMBER).txt.
> > > > How can i do?
> > > >
> > > > Thanks
> > > Hi!
> > > you mean to say like,want to save it in different file(total number of file will be DISCRETIZZAZIONE_X * DISCRETIZZAZIONE_Z)
> > > If so
> > > put your fopen command inside the llop & modify the parameters & logic so as to open
> > > files in write mode & close the files once written...
> > > I am not sure about its reliability,if needed thats the way you can do.....
> > >
> > > Shan.......
> >
> > Hi
> >
> > Oh no... the number of files i want to save is n_SEZIONE and i want to save them as
> > sliceHm(SLICE_NUMBER)...
> >
> > I mean, for every n there is a SLICE_NUMBER and i want to put this number in the file name.
> >
> > Thanks
> Hi,
> Oh...O.K.....
> Try something like this...
> fid = fopen( ['C:\Users\hp\Desktop\TESI\Modello.Seno\Phantom.1\sliceHm' num2str(SLICE_NUMBER) '.txt'],'wt');
> Shan......

Thanks Shan, it's exactly what i've done and it works very good.
In the same way now i've to open the saved .txt file in order to process them
Thanks
 

Subject: save file

From: Shanmugam Kannappan

Date: 22 Jul, 2009 12:30:23

Message: 9 of 11

"Nico zanette" <zannakill@hotmail.com> wrote in message <h470b7$a2u$1@fred.mathworks.com>...
> "Shanmugam Kannappan" <shanmugambe@gmail.com> wrote in message <h46t81$mei$1@fred.mathworks.com>...
> > "Nico zanette" <zannakill@hotmail.com> wrote in message <h46shf$80s$1@fred.mathworks.com>...
> > > "Shanmugam Kannappan" <shanmugambe@gmail.com> wrote in message <h46rn5$fdn$1@fred.mathworks.com>...
> > > > "Nico zanette" <zannakill@hotmail.com> wrote in message <h46qdr$1u0$1@fred.mathworks.com>...
> > > > > hi! i have this piece of code:
> > > > >
> > > > > for n = 1 : n_SEZIONE
> > > > >
> > > > > SLICE_NUMBER = R * n;
> > > > >
> > > > > fid = fopen ('C:\Users\hp\Desktop\TESI\Modello.Seno\Phantom.1\sliceHm.txt', 'wt');
> > > > > for J_X_FOR = 1 : DISCRETIZZAZIONE_X
> > > > > for K_X_FOR = 1 : DISCRETIZZAZIONE_Z
> > > > > SLICE_H(K_X_FOR, J_X_FOR) = MATRICE_3D_PROPRIETA(J_X_FOR, SLICE_NUMBER, K_X_FOR);
> > > > > fprintf (fid,'%1.1f\n',SLICE_H(K_X_FOR, J_X_FOR));
> > > > > end
> > > > > end
> > > > > fclose(fid);
> > > > >
> > > > > The problem is: i want to create a sliceHm.txt for every iteration of the for cylcle and to save it like SliceHm(SLICE_NUMBER).txt.
> > > > > How can i do?
> > > > >
> > > > > Thanks
> > > > Hi!
> > > > you mean to say like,want to save it in different file(total number of file will be DISCRETIZZAZIONE_X * DISCRETIZZAZIONE_Z)
> > > > If so
> > > > put your fopen command inside the llop & modify the parameters & logic so as to open
> > > > files in write mode & close the files once written...
> > > > I am not sure about its reliability,if needed thats the way you can do.....
> > > >
> > > > Shan.......
> > >
> > > Hi
> > >
> > > Oh no... the number of files i want to save is n_SEZIONE and i want to save them as
> > > sliceHm(SLICE_NUMBER)...
> > >
> > > I mean, for every n there is a SLICE_NUMBER and i want to put this number in the file name.
> > >
> > > Thanks
> > Hi,
> > Oh...O.K.....
> > Try something like this...
> > fid = fopen( ['C:\Users\hp\Desktop\TESI\Modello.Seno\Phantom.1\sliceHm' num2str(SLICE_NUMBER) '.txt'],'wt');
> > Shan......
>
> Thanks Shan, it's exactly what i've done and it works very good.
> In the same way now i've to open the saved .txt file in order to process them
> Thanks
>
Hi!
Use the dir command to extract all the txt files & loop it.
Ex:
TxtFls = dir('*.txt');
Shan....

Subject: save file

From: Nico zanette

Date: 27 Jul, 2009 08:15:05

Message: 10 of 11

"Shanmugam Kannappan" <shanmugambe@gmail.com> wrote in message <h470ov$7l1$1@fred.mathworks.com>...
> "Nico zanette" <zannakill@hotmail.com> wrote in message <h470b7$a2u$1@fred.mathworks.com>...
> > "Shanmugam Kannappan" <shanmugambe@gmail.com> wrote in message <h46t81$mei$1@fred.mathworks.com>...
> > > "Nico zanette" <zannakill@hotmail.com> wrote in message <h46shf$80s$1@fred.mathworks.com>...
> > > > "Shanmugam Kannappan" <shanmugambe@gmail.com> wrote in message <h46rn5$fdn$1@fred.mathworks.com>...
> > > > > "Nico zanette" <zannakill@hotmail.com> wrote in message <h46qdr$1u0$1@fred.mathworks.com>...
> > > > > > hi! i have this piece of code:
> > > > > >
> > > > > > for n = 1 : n_SEZIONE
> > > > > >
> > > > > > SLICE_NUMBER = R * n;
> > > > > >
> > > > > > fid = fopen ('C:\Users\hp\Desktop\TESI\Modello.Seno\Phantom.1\sliceHm.txt', 'wt');
> > > > > > for J_X_FOR = 1 : DISCRETIZZAZIONE_X
> > > > > > for K_X_FOR = 1 : DISCRETIZZAZIONE_Z
> > > > > > SLICE_H(K_X_FOR, J_X_FOR) = MATRICE_3D_PROPRIETA(J_X_FOR, SLICE_NUMBER, K_X_FOR);
> > > > > > fprintf (fid,'%1.1f\n',SLICE_H(K_X_FOR, J_X_FOR));
> > > > > > end
> > > > > > end
> > > > > > fclose(fid);
> > > > > >
> > > > > > The problem is: i want to create a sliceHm.txt for every iteration of the for cylcle and to save it like SliceHm(SLICE_NUMBER).txt.
> > > > > > How can i do?
> > > > > >
> > > > > > Thanks
> > > > > Hi!
> > > > > you mean to say like,want to save it in different file(total number of file will be DISCRETIZZAZIONE_X * DISCRETIZZAZIONE_Z)
> > > > > If so
> > > > > put your fopen command inside the llop & modify the parameters & logic so as to open
> > > > > files in write mode & close the files once written...
> > > > > I am not sure about its reliability,if needed thats the way you can do.....
> > > > >
> > > > > Shan.......
> > > >
> > > > Hi
> > > >
> > > > Oh no... the number of files i want to save is n_SEZIONE and i want to save them as
> > > > sliceHm(SLICE_NUMBER)...
> > > >
> > > > I mean, for every n there is a SLICE_NUMBER and i want to put this number in the file name.
> > > >
> > > > Thanks
> > > Hi,
> > > Oh...O.K.....
> > > Try something like this...
> > > fid = fopen( ['C:\Users\hp\Desktop\TESI\Modello.Seno\Phantom.1\sliceHm' num2str(SLICE_NUMBER) '.txt'],'wt');
> > > Shan......
> >
> > Thanks Shan, it's exactly what i've done and it works very good.
> > In the same way now i've to open the saved .txt file in order to process them
> > Thanks
> >
> Hi!
> Use the dir command to extract all the txt files & loop it.
> Ex:
> TxtFls = dir('*.txt');
> Shan....

Hi Shan. I made it this way because i must discriminate beetween sliceHm, sliceHp, slice Vm and sliceVp:

   for k = SLICE_NUMBER
        textfilename = ['sliceHm' num2str(k) '.txt'];
        textdata = load(textfilename);
            
        textfilename1 = ['sliceVm' num2str(k) '.txt'];
        textdata1 = load(textfilename1);

        textfilename2 = ['sliceHp' num2str(k) '.txt'];
        textdata2 = load(textfilename2);
        
        textfilename3 = ['sliceVp' num2str(k) '.txt'];
        textdata3 = load(textfilename3);
           
     end
and it works... i think. But now i have a big problem. i need to process this file cell by cell... i found troubles with the indexes... i try this:

INDICE_TESSUTI = 1;
p = 1;


for n = 1 : n_SEZIONE
    
    SLICE_NUMBER = R * n
    
    txtfile = ['C:\Users\hp\Desktop\TESI\Modello.Seno\Phantom.1\matriceHEi' num2str(SLICE_NUMBER) '.txt'];
    fid = fopen (txtfile, 'wt');
    

    for J_X_FOR = 1 : DISCRETIZZAZIONE_X
        for K_X_FOR = 1 : DISCRETIZZAZIONE_Z
  
            if (textdata(INDICE_TESSUTI)== -1)
            MATRICE_2D_PROPRIETA_H(K_X_FOR, J_X_FOR) = 1;
            
            elseif (textdata(INDICE_TESSUTI) == -2)
            MATRICE_2D_PROPRIETA_H(K_X_FOR, J_X_FOR) = 1;
            
            elseif (textdata(INDICE_TESSUTI) == -4)
            MATRICE_2D_PROPRIETA_H(K_X_FOR, J_X_FOR) = 1;
            
            elseif (textdata(INDICE_TESSUTI) == 1.1)
            MATRICE_2D_PROPRIETA_H(K_X_FOR, J_X_FOR) = textdata2(p)*1.000 + (1-textdata2(p))*6.151;
            
            elseif (textdata(INDICE_TESSUTI) == 1.2)
            MATRICE_2D_PROPRIETA_H(K_X_FOR, J_X_FOR) = textdata2(p)*6.151 + (1-textdata2(p))*7.821;
            
            elseif (textdata(INDICE_TESSUTI) == 1.3)
            MATRICE_2D_PROPRIETA_H(K_X_FOR, J_X_FOR) = textdata2(p)*7.821 + (1-textdata2(p))*9.941;
            
            elseif (textdata(INDICE_TESSUTI) == 2)
            MATRICE_2D_PROPRIETA_H(K_X_FOR, J_X_FOR) = textdata2(p)*9.941 + (1-textdata2(p))*4.031;
            
            elseif (textdata(INDICE_TESSUTI) == 3.1)
            MATRICE_2D_PROPRIETA_H(K_X_FOR, J_X_FOR) = textdata2(p)*4.031 + (1-textdata2(p))*3.140;
            
            elseif (textdata(INDICE_TESSUTI) == 3.2)
            MATRICE_2D_PROPRIETA_H(K_X_FOR, J_X_FOR) = textdata2(p)*3.140 + (1-textdata2(p))*2.908;
            
            elseif (textdata(INDICE_TESSUTI) == 3.3)
            MATRICE_2D_PROPRIETA_H(K_X_FOR, J_X_FOR) = textdata2(p)*2.908 + (1-textdata2(p))*2.293;
            
            fprintf (fid,'%1.5f\n',MATRICE_2D_PROPRIETA_H(K_X_FOR, J_X_FOR));
            end;
            
            %INDICE_TESSUTI = INDICE_TESSUTI +1;
            p = p + 1;
        end
    end
fclose(fid);

end

the index exceeds the matrix buonds... i don't know how to manage it.
I know... i'am a bad at programming...

Subject: save file

From: Nico zanette

Date: 28 Jul, 2009 06:16:02

Message: 11 of 11

"Nico zanette" <zannakill@hotmail.com> wrote in message <h4jnm9$evi$1@fred.mathworks.com>...
> "Shanmugam Kannappan" <shanmugambe@gmail.com> wrote in message <h470ov$7l1$1@fred.mathworks.com>...
> > "Nico zanette" <zannakill@hotmail.com> wrote in message <h470b7$a2u$1@fred.mathworks.com>...
> > > "Shanmugam Kannappan" <shanmugambe@gmail.com> wrote in message <h46t81$mei$1@fred.mathworks.com>...
> > > > "Nico zanette" <zannakill@hotmail.com> wrote in message <h46shf$80s$1@fred.mathworks.com>...
> > > > > "Shanmugam Kannappan" <shanmugambe@gmail.com> wrote in message <h46rn5$fdn$1@fred.mathworks.com>...
> > > > > > "Nico zanette" <zannakill@hotmail.com> wrote in message <h46qdr$1u0$1@fred.mathworks.com>...
> > > > > > > hi! i have this piece of code:
> > > > > > >
> > > > > > > for n = 1 : n_SEZIONE
> > > > > > >
> > > > > > > SLICE_NUMBER = R * n;
> > > > > > >
> > > > > > > fid = fopen ('C:\Users\hp\Desktop\TESI\Modello.Seno\Phantom.1\sliceHm.txt', 'wt');
> > > > > > > for J_X_FOR = 1 : DISCRETIZZAZIONE_X
> > > > > > > for K_X_FOR = 1 : DISCRETIZZAZIONE_Z
> > > > > > > SLICE_H(K_X_FOR, J_X_FOR) = MATRICE_3D_PROPRIETA(J_X_FOR, SLICE_NUMBER, K_X_FOR);
> > > > > > > fprintf (fid,'%1.1f\n',SLICE_H(K_X_FOR, J_X_FOR));
> > > > > > > end
> > > > > > > end
> > > > > > > fclose(fid);
> > > > > > >
> > > > > > > The problem is: i want to create a sliceHm.txt for every iteration of the for cylcle and to save it like SliceHm(SLICE_NUMBER).txt.
> > > > > > > How can i do?
> > > > > > >
> > > > > > > Thanks
> > > > > > Hi!
> > > > > > you mean to say like,want to save it in different file(total number of file will be DISCRETIZZAZIONE_X * DISCRETIZZAZIONE_Z)
> > > > > > If so
> > > > > > put your fopen command inside the llop & modify the parameters & logic so as to open
> > > > > > files in write mode & close the files once written...
> > > > > > I am not sure about its reliability,if needed thats the way you can do.....
> > > > > >
> > > > > > Shan.......
> > > > >
> > > > > Hi
> > > > >
> > > > > Oh no... the number of files i want to save is n_SEZIONE and i want to save them as
> > > > > sliceHm(SLICE_NUMBER)...
> > > > >
> > > > > I mean, for every n there is a SLICE_NUMBER and i want to put this number in the file name.
> > > > >
> > > > > Thanks
> > > > Hi,
> > > > Oh...O.K.....
> > > > Try something like this...
> > > > fid = fopen( ['C:\Users\hp\Desktop\TESI\Modello.Seno\Phantom.1\sliceHm' num2str(SLICE_NUMBER) '.txt'],'wt');
> > > > Shan......
> > >
> > > Thanks Shan, it's exactly what i've done and it works very good.
> > > In the same way now i've to open the saved .txt file in order to process them
> > > Thanks
> > >
> > Hi!
> > Use the dir command to extract all the txt files & loop it.
> > Ex:
> > TxtFls = dir('*.txt');
> > Shan....
>
> Hi Shan. I made it this way because i must discriminate beetween sliceHm, sliceHp, slice Vm and sliceVp:
>
> for k = SLICE_NUMBER
> textfilename = ['sliceHm' num2str(k) '.txt'];
> textdata = load(textfilename);
>
> textfilename1 = ['sliceVm' num2str(k) '.txt'];
> textdata1 = load(textfilename1);
>
> textfilename2 = ['sliceHp' num2str(k) '.txt'];
> textdata2 = load(textfilename2);
>
> textfilename3 = ['sliceVp' num2str(k) '.txt'];
> textdata3 = load(textfilename3);
>
> end
> and it works... i think. But now i have a big problem. i need to process this file cell by cell... i found troubles with the indexes... i try this:
>
> INDICE_TESSUTI = 1;
> p = 1;
>
>
> for n = 1 : n_SEZIONE
>
> SLICE_NUMBER = R * n
>
> txtfile = ['C:\Users\hp\Desktop\TESI\Modello.Seno\Phantom.1\matriceHEi' num2str(SLICE_NUMBER) '.txt'];
> fid = fopen (txtfile, 'wt');
>
>
> for J_X_FOR = 1 : DISCRETIZZAZIONE_X
> for K_X_FOR = 1 : DISCRETIZZAZIONE_Z
>
> if (textdata(INDICE_TESSUTI)== -1)
> MATRICE_2D_PROPRIETA_H(K_X_FOR, J_X_FOR) = 1;
>
> elseif (textdata(INDICE_TESSUTI) == -2)
> MATRICE_2D_PROPRIETA_H(K_X_FOR, J_X_FOR) = 1;
>
> elseif (textdata(INDICE_TESSUTI) == -4)
> MATRICE_2D_PROPRIETA_H(K_X_FOR, J_X_FOR) = 1;
>
> elseif (textdata(INDICE_TESSUTI) == 1.1)
> MATRICE_2D_PROPRIETA_H(K_X_FOR, J_X_FOR) = textdata2(p)*1.000 + (1-textdata2(p))*6.151;
>
> elseif (textdata(INDICE_TESSUTI) == 1.2)
> MATRICE_2D_PROPRIETA_H(K_X_FOR, J_X_FOR) = textdata2(p)*6.151 + (1-textdata2(p))*7.821;
>
> elseif (textdata(INDICE_TESSUTI) == 1.3)
> MATRICE_2D_PROPRIETA_H(K_X_FOR, J_X_FOR) = textdata2(p)*7.821 + (1-textdata2(p))*9.941;
>
> elseif (textdata(INDICE_TESSUTI) == 2)
> MATRICE_2D_PROPRIETA_H(K_X_FOR, J_X_FOR) = textdata2(p)*9.941 + (1-textdata2(p))*4.031;
>
> elseif (textdata(INDICE_TESSUTI) == 3.1)
> MATRICE_2D_PROPRIETA_H(K_X_FOR, J_X_FOR) = textdata2(p)*4.031 + (1-textdata2(p))*3.140;
>
> elseif (textdata(INDICE_TESSUTI) == 3.2)
> MATRICE_2D_PROPRIETA_H(K_X_FOR, J_X_FOR) = textdata2(p)*3.140 + (1-textdata2(p))*2.908;
>
> elseif (textdata(INDICE_TESSUTI) == 3.3)
> MATRICE_2D_PROPRIETA_H(K_X_FOR, J_X_FOR) = textdata2(p)*2.908 + (1-textdata2(p))*2.293;
>
> fprintf (fid,'%1.5f\n',MATRICE_2D_PROPRIETA_H(K_X_FOR, J_X_FOR));
> end;
>
> %INDICE_TESSUTI = INDICE_TESSUTI +1;
> p = p + 1;
> end
> end
> fclose(fid);
>
> end
>
> the index exceeds the matrix buonds... i don't know how to manage it.
> I know... i'am a bad at programming...

Anyone can help me please? :(

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
dir Sprinceana 22 Jul, 2009 08:41:30
fopen Sprinceana 22 Jul, 2009 08:41:30
reference us 22 Jul, 2009 06:59:12
faq us 22 Jul, 2009 06:59:12
evergreen us 22 Jul, 2009 06:59:12
save a txt file Sprinceana 22 Jul, 2009 06:48:42
rssFeed for this Thread

Contact us at files@mathworks.com