如何在 Matlab 中将数组打印到 .txt 文件?
我刚刚开始学习Matlab,所以这个问题可能非常基本:
我有一个变量
a=[2.3 3.422 -6.121 9 4.55]
,我希望将值输出到 .txt 文件,如下所示:
2.3
3.422
-6.121
9
4.55
我怎样才能做到这一点?
fid = fopen('c:\\coeffs.txt','w'); //this opens the file
//now how to print 'a' to the file??
I am just beginning to learn Matlab, so this question might be very basic:
I have a variable
a=[2.3 3.422 -6.121 9 4.55]
I want the values to be output to a .txt file like this:
2.3
3.422
-6.121
9
4.55
How can I do this?
fid = fopen('c:\\coeffs.txt','w'); //this opens the file
//now how to print 'a' to the file??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下应该可以解决问题:
有关详细信息,请查看 FOPEN 和 FPRINTF。
The following should do the trick:
For more info, check out the documentation for FOPEN and FPRINTF.