exp doesn't return the expected values
8 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Star Strider
on 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 Comments
Star Strider
on 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
on 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...
More Answers (0)
See Also
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!