user1782638
user1782638

Reputation: 130

Matlab number formatting?

I'm having some difficulties processing some numbers. The results I get are some like:

0.000093145+1.6437e-011i
0.00009235+4.5068e-009i

I've already try to use format long and as alternative passing to string and then str2num and with no good results also. Although is not being possible to convert them properly as I want (e.g. to a number with 9 decimals) If nobody is able to help me, at least I would appreciate if someone can tell me how to interpret the meaning of the i base.

Upvotes: 0

Views: 127

Answers (2)

Mano
Mano

Reputation: 887

After taking real() you can also control the decimal place formatting by sprintf:

sprintf('%0.2f', pi)

Will result in:

'3.14'

Place a 9 instead of a 2 for 9 decimal places.

Upvotes: 1

tashuhka
tashuhka

Reputation: 5126

You are talking about the imaginary unit i. If you are just using real number, you could neglect the imaginary part (it is very small). Thus, try:

real(0.000093145+1.6437e-011i)

Upvotes: 3

Related Questions