Borrar filtros
Borrar filtros

Change file name in loop

4 visualizaciones (últimos 30 días)
Krish Desai
Krish Desai el 25 de Mzo. de 2016
Comentada: Krish Desai el 25 de Mzo. de 2016
For some reason only one file dump_0 is being created. Does this mean Matlab is not going through the for loop?
for t=0:dt:4*dt %99 for 100 graphs
figure;
for ind=1:1920
U=(3*ind+linspace(1,3,3)-3);
Phi= PHI_disp_RBME_ModePlot_N(U);
r=xlocs_full(ind);
omega=(f_disp_RBME(iMode,kPtMode)*2*pi);
k=kappa_space(kPtMode);
spatialphase=k*r;
timephase=omega*t;
displ=Phi*exp(i*((spatialphase)-(timephase)));
xOvito(ind)=xOvito(ind)+magFact*displ(1);
yOvito(ind)=yOvito(ind)+magFact*displ(2);
zOvito(ind)=zOvito(ind)+magFact*displ(3);
header1= 'id';
header2= 'type';
header3='x';
header4='y';
header5='z';
k=0;
fileName='Dump_';
fid=fopen([fileName,num2str(k)],'w');
fprintf(fid, [ header1 ' ' header2 ' ' header3 ' ' header4 ' ' header5 '\n']);
fprintf(fid, '%f %f %f \n', [xOvito yOvito zOvito]');
fclose(fid);
k=k+1;
...
end

Respuestas (1)

Walter Roberson
Walter Roberson el 25 de Mzo. de 2016
You have
k=0;
inside the loop, so you are resetting the name each time.
  1 comentario
Krish Desai
Krish Desai el 25 de Mzo. de 2016
I put it outside all the loops, at the top, I still only got one file: dump_0.040673

Iniciar sesión para comentar.

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by