Display array values of varying orders of magnitude

1 Ansicht (letzte 30 Tage)
David
David am 18 Jan. 2012
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?

Akzeptierte Antwort

Matt Tearle
Matt Tearle am 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')

Weitere Antworten (0)

Kategorien

Mehr zu Cell Arrays finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by