MATLAB: I’d like to create a loop that each create a new .txt file.

for looptxt

im trying to create 516 files in with the k loop, what is the correct syntax?
for k=1:516
fid = fopen("test.txt",'wt')
for j=1:5
formatSpec='%1.3f,%s,0,00,0\n%1.3f,%s,1,00,0\n%1.3f,%s,2,00,0\n';
fprintf(fid,formatSpec,time,a1,time,a2,time,a3)
time=time+0.001
end
fclose(fid);
end

Best Answer

https://www.mathworks.com/help/matlab/import_export/process-a-sequence-of-files.html use dlmwrite to write text files and sprintf() appropriately as mentioned in the link
Related Question