![]() |
如何在MATLAB中使用循环变量创建字符串?
我有这样一个循环:
for i=1:no %some calculations fid = fopen('c:\\out.txt','wt'); %write something to the file fclose(fid); end 我希望将数据写入这样的不同文件中: [LIST][*]对于i=1 ,数据被写入out1.txt[*]对于i=2 ,数据被写入out2.txt[*]对于i=3 ,数据被写入out3.txt[*]等等[/LIST]做'out'+ i行不通。 [B]如何才能做到这一点?[/B] 回答: 另一个选择是函数[URL="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/sprintf.html"]SPRINTF[/URL] : fid = fopen(sprintf('c:\\out%d.txt',i),'wt'); [url=https://stackoverflow.com/questions/1687605]更多&回答...[/url] |
所有时间均为北京时间。现在的时间是 20:23。 |
Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.