Effacer les filtres
Effacer les filtres

Change file name in loop

4 vues (au cours des 30 derniers jours)
Krish Desai
Krish Desai le 25 Mar 2016
Commenté : Krish Desai le 25 Mar 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

Réponses (1)

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

Connectez-vous pour commenter.

Catégories

En savoir plus sur Startup and Shutdown dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by