Round saved variables (not command line output) to 5 decimal places

I am trying to create a series starting at 0.00625 km, with a step of 0.00625 km i.e. the first three terms would be: 0.00625 0.0125 0.01875 .... I am creating this series using:
dx=0.00625;
xstart=0.00625;
xend=35;
vbx=(xstart:dx:xend);
However the variable vbx is only saving to 4 decimal place precision i.e. 0.0063 0.0125 0.0188 ...
I need the actual variable that is saved to have the correct precision - the output on the command line is not important.
Could someone tell me how to go about this?
round does not work unfortunately, I think that this is an error due to the class of the numbers?

 채택된 답변

Stephen23
Stephen23 2016년 4월 22일
편집: Stephen23 2016년 4월 22일
MATLAB has not eaten your digits, you just need to change the format to display them:
>> vbx(1:5) % default format == short
ans =
0.0063 0.0125 0.0188 0.0250 0.0313
>> format longg
>> vbx(1:5)
ans =
0.00625 0.0125 0.01875 0.025 0.03125
Note that if you are using save then its precision is controlled by an optional input argument, and not the command window format.

댓글 수: 2

Thanks for this. If you are looking at variables by double clicking on them from the Workspace (as I do) it doesn't show you the full number unless you click into a cell. Which I have now just realised and was causing the confusion! Cheers.
There is a preference that controls the format used by the browser

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

질문:

K G
2016년 4월 22일

댓글:

2016년 4월 23일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by