How to get an exponent of scientific notation in Matlab

When the numbers are really small, Matlab automatically displays them in Scientific Notation format.

Example:

A = rand(3) / 10000000000000000;

A =

  1.0e-016 *

    0.6340    0.1077    0.6477
    0.3012    0.7984    0.0551
    0.5830    0.8751    0.9386

Is there a built-in function that returns the exponent? Something like getExponent(A) = -16:?

I know this is kind of a dumb question, but I need to check hundreds of matrices, and I can't figure it out.

Thank you for your help.

+5
source share
2 answers

Basic math can tell you that:

floor(log10(N))

The base base of number 10 tells you about how many digits before the decimal point are in this number.

For example, 99987123459823754there is9.998E+016

log10(99987123459823754) 16.9999441, 16, : " - 16, 17".

, :

0.000000000003754 = 3.754E-012
log10(0.000000000003754) = -11.425
floor(log10(0.000000000003754)) = -12
+13

log10(A). , , A. (< 1),

min(floor(log10(A)))

, - :

a = log10(A);
[v i] = max(ceil(abs(a)));
exponent = v * sign(a(i));

. , A = [1e-6 1e20], 20.

, Matlab , . , A 1 (, A = [100, 203]), , 2. , , .

+3

All Articles