Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display with n decimal places in Matlab

I was wondering how to use command to set up displaying with n decimal places in Matlab?

Must n be restricted to some predetermined numbers? Or one can just specify any for n?

Thanks and regards!

like image 389
Tim Avatar asked Mar 01 '11 00:03

Tim


2 Answers

You can convert a number to a string with n decimal places using the SPRINTF command:

>> x = 1.23;
>> sprintf('%0.6f', x)

ans =

1.230000

>> x = 1.23456789;
>> sprintf('%0.6f', x)

ans =

1.234568
like image 65
b3. Avatar answered Sep 28 '22 02:09

b3.


This site might help you out with all of that:

http://herz-fischler.ca/MATLAB/section15.html

like image 33
Dbz Avatar answered Sep 28 '22 00:09

Dbz