Display array values of varying orders of magnitude
1 次查看(过去 30 天)
显示 更早的评论
I store a function's input parameters in an array, and I want the values in the array printed in the Command Window when an error occurs.
The array's values span many orders of magnitude (1e-4 up to 1e16). When printed, at the top of the printed data one sees "1.0e+16 *" and then underneath each array value listed as a zero, except that which is on the order of 1e16. That is listed as a number between 1 and 10.
Is there an easy way to print all values of the array in their own respective order of magnitude?
0 个评论
采纳的回答
Matt Tearle
2012-1-18
fprintf with the e format will put everything in exponential notation:
x = [1.234e16,42;0.3,6.789e8]
fprintf([repmat('%7.4e ',1,size(x,2)),'\n'],x')
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Cell Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!