matlab 的 fortran 格式等效项
matlab相当于
write(1,'("Speed, resistance, power",3f8.2)')(a(i),i=1,3)
我已经尝试过
a = [10. 20. 200.]
fprintf(unit1,'a = 3%8.1e',a)
但我仍然遇到问题(整个matlab输出格式化的事情)。
为肯尼编辑:对于上面给出的 a 值,它将给出(在新行中):
Speed, resistance, power 10.00 20.00 200.00
What would be matlab's equivalent of
write(1,'("Speed, resistance, power",3f8.2)')(a(i),i=1,3)
I've tried
a = [10. 20. 200.]
fprintf(unit1,'a = 3%8.1e',a)
but I'm still having trouble with it (the whole matlab output formatting thing).
Edit for Kenny: for the values of a as given above, it would give (in a new row):
Speed, resistance, power 10.00 20.00 200.00
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我使用 1 作为 fileID 写入命令窗口,并在末尾添加了一个换行符,因为它更漂亮,但这应该会重现您想要的内容
编辑
假设一个数组
a。进一步假设我们想要逐行打印它
注意:这会在同一行上打印所有行(谢谢,@JS)。
I'm using 1 for fileID to write to the command window, and I put a newline in the end because it's prettier, but this should reproduce what you want
EDIT
Assume an array
a
of unknown dimensions. Assume further that we want to fprint it row by rowNote: This prints all rows of a one after the other on the same line (thanks, @JS).