Trying to understand the format SHORT setup

I am learning MATLAB from the fundamentals and I have encountered this section about the format SHORT setup which is the default. From the documentation it says that this setting is used by default and that it is meant to return 5-digit scaled, fixed-point values.
For example, when I try these:
>> 12.5
ans =
12.5000
>> pi
ans =
3.1416
>> 88854.2301
ans =
8.8854e+04
I notice that there are always 4 digits after the decimal point. So what is the meaning of the "5-digital scaled"? I quite fail to understand it.

 Accepted Answer

Five decimal digits = one to the left of the decimal, four to the right of the decimal, and exponential notation as necessary.
Experiment with the other format options as well, to see how they work.

2 Comments

Now I get it. Just one last doubt: what makes the exponential appear? I mean, when is the exponential deemed necessary and when is it not?
>> 65.11
ans =
65.1100
>> 650.11
ans =
650.1100
>> 6500.11
ans =
6.5001e+03
On the last command, why is the exponential notation returned by MATLAB? Or is it prohibited to use a number with more than 3 digits before the decimal point?
It appears to increase the precision depending on the argument. If it needs more precision to present the result, it uses it, even if the extra digits to the right of the decimnal are not shown:
Example —
6500
6500.01
6500.11
produces:
ans =
6500
ans =
6.5000e+03
ans =
6.5001e+03
I am not certain how that is coded, so I cannot comment on the logic itself.

Sign in to comment.

More Answers (0)

Products

Release

R2019b

Community Treasure Hunt

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

Start Hunting!