Tried to use sprintf, only created one file....
%TimeStep
%kPtMode=3;
%iMode=6;
dt=5*10e-5;
steps=4;
for t=0:dt:steps*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);
end
plot3(xOvito,yOvito,zOvito,'ko','markerfacecolor','r', 'markersize', 7);
xrotation = 0;
yrotation = 0;
view(xrotation, yrotation);
xlabel('x')
ylabel('y')
zlabel('z')
axis equal
xview=0;
yview=0;
view(xview,yview);
header1= 'id';
header2= 'type';
header3='x';
header4='y';
header5='z';
filename=sprintf('%s_%d','filename',i);
fid=fopen(filename,'w');
%fprintf(fid, [header 1 ' ' header 2 ' ' header 3 ' ' header 4 ' ' header 5 ' '\n']);
fprintf(fid, [ header1 ' ' header2 ' ' header3 ' ' header4 ' ' header5 '\n']);
fprintf(fid, '%f %f %f \n', [xOvito yOvito zOvito]');
fclose(fid);
end
end