user494461
user494461

Reputation:

matlab returns values as 1.0e+04 * something, how to get the final value?

Matlab returns values as

1.0e+04 * [matrix here]

some of the values inside the matrix are 0.1981, 0.5765, etc...

How to get the answer in this representation 1981, 5765, etc... instead of 1.e+04 *

Upvotes: 3

Views: 25696

Answers (2)

Eitan T
Eitan T

Reputation: 32930

This is actually just MATLAB's way to display the output. You have to use the format command to change the display formatting, like this:

format bank

This should force MATLAB to display the numbers with precision of two places after the decimal point.

To revert to the default formatting, just type:

format


Example:

A = 1e5 * rand(2)
A =

  1.0e+004 *

    7.4701    9.7694
    9.7517    6.7675

format bank
A

A =

  74700.70      97693.76
  97516.71      67675.22    

P.S.

If your matrix contains only integers, you can use uint32(A) or uint64(A) too:

B = ceil(A);
uint32(B)

ans =
       74701       97694
       97517       67676

Upvotes: 7

mathematician1975
mathematician1975

Reputation: 21351

Change the format. Try

 format long

and then check your output. There are other format options you can use if this is not what you want http://www.mathworks.co.uk/help/techdoc/ref/format.html

Upvotes: 3

Related Questions