What to do when MatLab loses format longE midway and no longer outputs scientific notation?

조회 수: 5 (최근 30일)
MatLab loses format longE midway through the calculation and no longer expresses numerical output using scientific notation. What to do next??
First line of code implements 'format longE'. Calculation proceeds with output expressed in scientific notation. Somewhere towards the last part of the code, numerical output reverts and is expressed in decimal format; it's no longer format longE. Even inserting a second 'format longE' before the loss point doesn't help. What to do next??

답변 (3개)

Star Strider
Star Strider 2016년 7월 6일
편집: Star Strider 2016년 7월 6일
I can’t say for certain because I don’t have your code or data. The documentation for format notes:
  • MATLAB always displays integer data types to the appropriate number of digits for the data type. For example, MATLAB uses 3 digits to display int8 data types (for instance, -128:127). Setting the output format to short or long does not affect the display of integer-type variables.
  • Integer-valued, floating-point numbers with a maximum of 9 digits do not display in scientific notation.
That’s the only possibility I can think of (other than some function resetting the format) that could do what you’re seeing. In that event, it’s not the format but the data type that’s resulting in the display difference.

Steven Lord
Steven Lord 2016년 7월 6일
At the point where you "lose" format longe, does the type of the data you're displaying change? For instance, are your variables now sym or a fixed-point type instead of double?

Anthony DeGance
Anthony DeGance 2016년 7월 6일
Star Strider,
Thank you for your input. I see now that I should have specified that I'm outputing numeric non-integer data with vpa, e.g. ChekSumNorm = 1.1754943508222875079687365372222e-38, really ugly looking stuff. Because I'm summing infinite series, the numeric output is expressed scientifically from the get-go. But I will follow up on your suggestion to examine the output data types which are a mix of double and sym.
  댓글 수: 1
Star Strider
Star Strider 2016년 7월 6일
The Symbolic Math Toolbox precision is governed by the digits function. Casting them to double converts them to the default 64-bit representation.

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

카테고리

Help CenterFile Exchange에서 Conversion Between Symbolic and Numeric에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by