我有这样一个循环:
for i=1:no %some calculations fid = fopen('c:\\out.txt','wt'); %write something to the file fclose(fid); end 我希望将数据写入这样的不同文件中:
- 对于i=1 ,数据被写入out1.txt
- 对于i=2 ,数据被写入out2.txt
- 对于i=3 ,数据被写入out3.txt
- 等等
做'out'+ i行不通。
如何才能做到这一点?
回答:
另一个选择是函数
SPRINTF :
fid = fopen(sprintf('c:\\out%d.txt',i),'wt');
更多&回答...