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!