Laz*_*zer 10 arrays file-io matlab text-files
我刚刚开始学习Matlab,所以这个问题可能非常基础:
我有一个变量
a=[2.3 3.422 -6.121 9 4.55]
Run Code Online (Sandbox Code Playgroud)
我希望将值输出到.txt文件,如下所示:
2.3
3.422
-6.121
9
4.55
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?
fid = fopen('c:\\coeffs.txt','w'); //this opens the file
//now how to print 'a' to the file??
Run Code Online (Sandbox Code Playgroud)
gno*_*ice 15
以下应该做的伎俩:
fid = fopen('c:\\coeffs.txt','wt'); % Note the 'wt' for writing in text mode
fprintf(fid,'%f\n',a); % The format string is applied to each element of a
fclose(fid);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
49566 次 |
| 最近记录: |