format short;
A = 12.3456789
B = 1234.56789
Output is:
A = 12.3457
B = 1.2346e+03
Why is output A not "1.2345e+01"? What does format "short" do?

 채택된 답변

dpb
dpb 2016년 7월 20일

1 개 추천

Per the "Algorithms" notes in the doc, "If the largest element of a matrix is larger than 103 or smaller than 10-3, then MATLAB applies a common scale factor for the short and long format."
I hadn't really tested before, I thought it was a %g format but it doesn't actually follow those rules which count the number of significant digits to be shown. It's internal as above says purely only magnitude of exponent >3

댓글 수: 2

SP
SP 2016년 7월 22일
btw where do yo find the "Algorithms" notes?
Stephen23
Stephen23 2016년 7월 22일
편집: Stephen23 2016년 7월 22일
@SP: open the MATLAB help for format (not online, the actual MATLAB help). Scroll to the very bottom. Look for the heading "More About": click the "> Algorithms" text.

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

추가 답변 (0개)

카테고리

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

태그

질문:

SP
2016년 7월 20일

편집:

2016년 7월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by