exp doesn't return the expected values
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Ahmed
am 22 Jul. 2022
Kommentiert: Steven Lord
am 22 Jul. 2022
I have a matrix which is defined like this
x = [1 2 3; 4 5 6; 7 8 9];
y = exp(x)
Why am I getting this result ? I expected a matrix which contains element by element exp
0 Kommentare
Akzeptierte Antwort
Star Strider
am 22 Jul. 2022
That is esactly what it is doing —
format longG
x = [1 2 3; 4 5 6; 7 8 9];
y = exp(x)
y11 = exp(1)
y33 = exp(9)
What were you expecting?
.
3 Kommentare
Star Strider
am 22 Jul. 2022
No worries!
The ‘1.0e+3’ in the upper left of the display indicates that the entire displayed matrix is multiplied by the inverse of that number, ‘1E-3’ in this instance.
.
Steven Lord
am 22 Jul. 2022
I'm guessing they missed the factor of 1.0e+03 in the upper-left corner of the matrix and so thought MATLAB was returning 0.0027 for exp(1) when they expected 2.71828...
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical 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!