Changing the number of decimal points for a complex double array
Show older comments
Hello all ,
I am calculating the eigen vectors for a matrix , the output of the function stores the result as a complex double. but the problem is that it saves only to the 4th decimal point and rounds up . for example : instead of -0.99995+0.00000j it is stored as -1.0000+0.0000j . This is a problem as when it tries to save 0.00003+0.00690j as 0.0000+0.0069j. When I display the output matrix in the command window it shows the variable normally as double-precision floating-point values that are 8 bytes (64 bits). but when saving in the workspace , it does the rounding . This can be very critical as it these calcuations are related to sensitivity analysis to power system. The code used is simply as follows:
A=[ -1 0 -990;
0.04714 -0.4762 0;
0 100 -100];
e=eig(A);
[V,D,W]=eig(A);
and the result in the command window as follows:
V =
Columns 1 through 2
-0.999952261875921 + 0.000000000000000i -0.999952261875921 + 0.000000000000000i
0.000027567894396 + 0.006899820799505i 0.000027567894396 - 0.006899820799505i
0.000501495829522 + 0.006900303189568i 0.000501495829522 - 0.006900303189568i
Column 3
0.994990280675026 + 0.000000000000000i
-0.000469071210390 + 0.000000000000000i
0.099970602351055 + 0.000000000000000i
but in the work space saved as follows:

Can anyone please help i how to save that matrix in the same format as it is computed ? .Thanks in advance .
3 Comments
madhan ravi
on 7 Apr 2019
Type
format long % and try again , perhaps?
Abdelrahman Elhawash
on 7 Apr 2019
John D'Errico
on 8 Apr 2019
No. MATLAB does indeed store a number as a double in more than 4 digits. Format does only change how the number is displayed. But nothing impacts how many digits are stored as a double.
When you look at the number in the workspace browser, that is not in fact how it is stored!
Accepted Answer
More Answers (1)
Walter Roberson
on 8 Apr 2019
1 vote
Go into preferences for workspace and change the default display format. The default format for the workspace viewer is not affected by the "format" command.
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!