フィルターのクリア

Change file name in loop

4 ビュー (過去 30 日間)
Krish Desai
Krish Desai 2016 年 3 月 25 日
コメント済み: Krish Desai 2016 年 3 月 25 日
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

回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 3 月 25 日
You have
k=0;
inside the loop, so you are resetting the name each time.
  1 件のコメント
Krish Desai
Krish Desai 2016 年 3 月 25 日
I put it outside all the loops, at the top, I still only got one file: dump_0.040673

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by