|
"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...
|