2

Example command and output:

>> 15.12

ans =

  15.119999999999999"

I'm trying to show only two significant digits (I'm putting values into a uitable) so this is driving me crazy.

Luis Mendo
  • 110,752
  • 13
  • 76
  • 147
user1949902
  • 361
  • 3
  • 9

2 Answers2

3

The most likely cause is that you have set format long.

Try typing format or format short at Matlab prompt.

Example:

>> format long
>> 15.12
ans 
  15.119999999999999   
>> format
>> 15.12
ans =
   15.1200
Luis Mendo
  • 110,752
  • 13
  • 76
  • 147
1

If you just want to show two digits use

>> format bank
>> 15.2

ans =

         15.20

See the Matlab Doc for further details.

Deve
  • 4,528
  • 2
  • 24
  • 27