exp doesn't return the expected values
9 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Star Strider
le 22 Juil 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 commentaires
Star Strider
le 22 Juil 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
le 22 Juil 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...
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!