A colleague of mine asked me yesterday that he wanted to get more decimal places on some numerical computation he was carrying out in MATLAB. He was actually using the curve fitting toolbox to fit a custom function and obtain two parameters `a`

and `b`

, but he would get something like `a=1.345`

, and he wanted to know at least two or three more decimal places. Typically the numeric information for these data is sitting in double precision in the MATLAB variables, however you have to know how to change the default format how MATLAB displays numbers to get it in the numeric format you want.

This post in the blog Loren on the Art of MATLAB explains the details. The short explanation is to use the `format`

function. The default option is `short`

, so if you write `pi`

at the command line you get `ans = 3.1416`

, but if you the write `format long`

before calling `pi`

, this time you get `ans = 3.141592653589793`

. There are also other types of notation depending on what you need.

### Like this:

Like Loading...

*Related*