I was wondering how to use the command to configure the display with n decimal places in Matlab?
Should I be limited to some predefined numbers? Or can you just specify any for n?
Thank you and welcome!
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
This site can help you with this:
http://herz-fischler.ca/MATLAB/section15.html
I use tim say sprintf('%0.6f', x) , this is a string, then I change it to a number using the str2double(x) command.
sprintf('%0.6f', x)
str2double(x)