MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply Today**New to MATLAB?**

Asked by dav
on 5 Apr 2013

Hi,

I am running a large simulation in matlab. I have noticed that matlab rounds off after 4 decimal places and this affects my results.

Is there a way to give a command **at the beginning of the program** so that matlab does the round off after about 10 decimal places?

Thanks.

*No products are associated with this question.*

Answer by Azzi Abdelmalek
on 5 Apr 2013

Accepted answer

format long

dav
on 5 Apr 2013

thanks

should you put a ";" after this command?

And is there a way to specify the number of decimal places?

## 1 Comment

## Roger Stafford

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/70054#comment_141515

Matlab's 'double' does not round off after four decimals as far as the actual computations are concerned. It is always accurate to about 16 significant decimal digits. It's only the display of its results that is given to four digits if you are using format short. It is important to understand the difference.

Try this experiment.

The second display is accurate to 16 places which means that this was the accuracy of the original computation. The 'short' format only displayed four of the significant digits.