Matlab中,把矩阵的数据输出为txt文本,如何让文本结果显示为“a(行列数)=数据”?a=[17,24,1,8,15,23,5,7,14,16]; for i=1:25fid = fopen('a.txt','wt'); fprintf(fid,'a(%d)=%g\n',i,a); fclose(fid);以上为Matlab程序,希望得

来源:学生作业帮助网 编辑:作业帮 时间:2024/04/29 01:25:21
Matlab中,把矩阵的数据输出为txt文本,如何让文本结果显示为“a(行列数)=数据”?a=[17,24,1,8,15,23,5,7,14,16]; for i=1:25fid = fopen('a.txt','wt'); fprintf(fid,'a(%d)=%g\n',i,a); fclose(fid);以上为Matlab程序,希望得

Matlab中,把矩阵的数据输出为txt文本,如何让文本结果显示为“a(行列数)=数据”?a=[17,24,1,8,15,23,5,7,14,16]; for i=1:25fid = fopen('a.txt','wt'); fprintf(fid,'a(%d)=%g\n',i,a); fclose(fid);以上为Matlab程序,希望得
Matlab中,把矩阵的数据输出为txt文本,如何让文本结果显示为“a(行列数)=数据”?
a=[17,24,1,8,15,23,5,7,14,16];
for i=1:25
fid = fopen('a.txt','wt');
fprintf(fid,'a(%d)=%g\n',i,a);
fclose(fid);
以上为Matlab程序,希望得到的a.txt文本里面的显示结果为
a(1)=17
a(2)=24
.
a(10)=16

Matlab中,把矩阵的数据输出为txt文本,如何让文本结果显示为“a(行列数)=数据”?a=[17,24,1,8,15,23,5,7,14,16]; for i=1:25fid = fopen('a.txt','wt'); fprintf(fid,'a(%d)=%g\n',i,a); fclose(fid);以上为Matlab程序,希望得

你已经快接近了,以后有什么不懂的可以在命令窗口里面输入 doc+"你要查询的函数"自己看帮助文件.

你的程序要这么改:

a=[17,24,1,8,15,23,5,7,14,16]; 
fid = fopen('a.txt','wt'); 
for i=1:length(a)
    fprintf(fid,'a(%d)=%g\n',i,a(i));
end     
fclose(fid);

就可以到达你的效果.