Question

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.

Était-ce utile?

La solution

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

Autres conseils

If you just want to show two digits use

>> format bank
>> 15.2

ans =

         15.20

See the Matlab Doc for further details.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top