MATLAB Answers

Numbers in command window printed 10000 times smaller

9 views (last 30 days)
Alex Dimko
Alex Dimko on 26 Oct 2020
Commented: Star Strider on 26 Oct 2020
I have this assignment and I wrote the code for the first paragraph.
The problem now is that the numbers printed in the command window seem to be 10000x smaller than those in the txt file.
I have linked both documents and s snippet from my code.


Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 26 Oct 2020
Edited: Star Strider on 26 Oct 2020
I suspect there is an exponent indication out-of-view in the image you posted.
When I read and reshape your file as in your previous Quesion, then display part of it:
format short
MatrixSegment = Dm(:, 1:2000:end)
the result is:
MatrixSegment =
1.0e+03 *
0 0.0250 0.0500 0.0750 0.1000 0.1250 0.1500 0.1750
0.0221 0.5001 0.6421 0.7601 1.0171 1.1331 1.2931 1.4421
0.8147 0.7449 0.4271 0.2323 0.6791 0.1538 0.5812 0.3430
0.5000 0.0147 0.2661 0.8725 0.9134 0.3267 0.0030 0.4337
Note the ‘1.0e+3 *’. That is the multiplier for the entire matrix.
EDIT — (26 Oct 2020 at 17:02)
Corrected typographical error.


Show 7 older comments
Alex Dimko
Alex Dimko on 26 Oct 2020
fid = fopen("UE1.txt", "r");
S=fread(fid,inf, "char=>char");
fid = fclose(fid);
data = [];
start = 1;
for index = 1:length(S)
if S(index) == ","
new_value = str2double(S(start:index-1));
data = [data new_value];
start = index+1;
data = reshape(data, 4, []);
data = data'
format long g
Alex Dimko
Alex Dimko on 26 Oct 2020
I changed the reshape with your reshape and transposed everything.
Now it works.
After 2 days of torture.
Star Strider
Star Strider on 26 Oct 2020
As always, my pleasure!
If my other Answer worked for you, I would appreciate it if you would Accept it as well!

Sign in to comment.

More Answers (1)

Walter Roberson
Walter Roberson on 26 Oct 2020
My recommendation would be that you go into Preferences -> Command Window -> Text Display, and choose numeric display "long g", and also Preferences -> Variables -> Default array format: and select "long g" (this affects the Variable Browser)
Then give the command
format long g
and display your numbers again.
What you overlooked is that the first line of output said
1e4 *


Alex Dimko
Alex Dimko on 26 Oct 2020
This is what I get.
now there are 2 columns, the numbers are aligned weird and I still cannot see the beginning.
But now the numbers are as they should be.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by