diag problem while substracting
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Erdogan Bulut Kul
am 21 Dez. 2017
Bearbeitet: James Tursa
am 21 Dez. 2017
my rho total is a square matrix, and when I do that:
diag(rho_total-1)
it gives me
1.0e-15 *
0.444089209850063
0.444089209850063
-0.111022302462516
-0.111022302462516
-0.222044604925031
0.666133814775094
why is that e-15 there?
0 Kommentare
Akzeptierte Antwort
James Tursa
am 21 Dez. 2017
Bearbeitet: James Tursa
am 21 Dez. 2017
It's just a display format thing. It means each number shown is actually multiplied by 1.0e-15
E.g.,
>> [1 2 3]
ans =
1 2 3
>> [1e-16 2e-16 3e-16]
ans =
1.0e-015 *
0.1000 0.2000 0.3000
So the diagonal numbers of rho_total you show in your post were actually pretty close to 1, since the difference between them and 1 is close to eps(1).
1 Kommentar
James Tursa
am 21 Dez. 2017
Bearbeitet: James Tursa
am 21 Dez. 2017
Consider this example:
>> [1 1;1 1]
ans =
1 1
1 1
>> [1-eps 1;1 1+eps]
ans =
1.0000 1.0000
1.0000 1.0000
>> diag([1-eps 1;1 1+eps] - 1)
ans =
1.0e-015 *
-0.2220
0.2220
E.g., you can get those trailing .0000 digits printed when the numbers are not exactly integers. Subtracting the integer reveals the difference between what is really there and what is printed to the screen. In your case, whatever floating point calculations were done to produce rho_total did not result in exact 1's on the diagonal. They were very close (relative to 1), but not exactly 1.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!