MATLAB result is inappropriate

I am new to MATLAB, I can not get the answer in the format I need. I have a main function call, but each program execution gives the result in the following format:

357341279027200000/23794118819840001

It must be a decimal, for example, for the same performance: 15.0181.

I could not understand why this is happening? Can you help me, thanks!

+3
source share
3 answers

Type format longon the command line or in a script.

If this does not work because the value is too large, try using vpa

+5
source

Note that this is just a visual, internally computed value is accurate.

>d  = 357341279027200000/23794118819840001
d =
   15.0181
>> d * 23794118819840001 == 357341279027200000
ans =
     1
>> 15.0181 * 23794118819840001 == 357341279027200000
ans =
     0
+2
source

, rat (). . , long format long g (Long g , 10 .)

0
source

Source: https://habr.com/ru/post/1786764/


All Articles