还是不能实现阿!我使用以下方法
for km=1:1000
NumL= ['tezhen' num2str(km) '.mat'];
save NumL l damp freq; %l damp freq 为每次循环的得到的结果,均为矩阵
end
可是结果均保存在NumL.mat中,而且只保存了最后一次结果,前面循环的结果被覆盖了。我本想保存在tezhen1.mat , tezhen2.mat……中的。而且我想把这些文件保存在指定的目录文件夹中,而不是当前工作目录中。初学MATLAB,请高手指点!
result = [5,6,7,8,9];
a1= 0:0.5:5;
for m=1:length(a1)
ts=int2str(m);
temp=a1(m)*6;
result=[result,temp];
fp=fopen(['d:\xxx\',ts,'.txt'],'a');%保存在d:\xxx文件夹下,以循环变量为文件名
fprintf(fp,'%5f ',result);
fclose(fp);
end
Help save ...
"Saving complex data with the -ascii option causes the imaginary part of the data to be lost, as MATLAB cannot load nonnumeric data ('i')."