exp doesn't return the expected values

10 次查看(过去 30 天)
I have a matrix which is defined like this
x = [1 2 3; 4 5 6; 7 8 9];
y = exp(x)
y = 3×3
1.0e+03 * 0.0027 0.0074 0.0201 0.0546 0.1484 0.4034 1.0966 2.9810 8.1031
Why am I getting this result ? I expected a matrix which contains element by element exp

采纳的回答

Star Strider
Star Strider 2022-7-22
That is esactly what it is doing —
format longG
x = [1 2 3; 4 5 6; 7 8 9];
y = exp(x)
y = 3×3
1.0e+00 * 2.71828182845905 7.38905609893065 20.0855369231877 54.5981500331442 148.413159102577 403.428793492735 1096.63315842846 2980.95798704173 8103.08392757538
y11 = exp(1)
y11 =
2.71828182845905
y33 = exp(9)
y33 =
8103.08392757538
What were you expecting?
.
  3 个评论
Star Strider
Star Strider 2022-7-22
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.
See the documentation on format for examples.
.
Steven Lord
Steven Lord 2022-7-22
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...

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

产品


版本

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by