Display array values of varying orders of magnitude

1 view (last 30 days)
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?

Accepted Answer

Matt Tearle
Matt Tearle on 18 Jan 2012
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')

More Answers (0)

Categories

Find more on Cell Arrays in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!