format short, format long, format short E, format long E, format rat
16 次查看(过去 30 天)
显示 更早的评论
How can i represent a number let's say 1231312.1232323 with the formats long/short/long e /short e /rat more elegant or in a single code line without having to write 10 colums i was thinking of the fprintf and format spec commands . P.S i'm very much a beginner in matlab :) .
0 个评论
采纳的回答
Rik
2020-10-28
For a single value I would suggest the fprintf function:
v=1234567.1234567;
fprintf('%.7f\n',v)
4 个评论
Rik
2020-10-28
Maybe it is just that I prefer having full control by using fprintf or sprintf, and I don't see the benefit of spamming the command window with the same value in different formats.
But at least you have an example here of how you can convert one syntax for format to another, and how you can use any object array in a for loop, which will then be processed column by column.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!