Domanda

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.

È stato utile?

Soluzione

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

Altri suggerimenti

If you just want to show two digits use

>> format bank
>> 15.2

ans =

         15.20

See the Matlab Doc for further details.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top