How do you put the constant e on matlab

1.017 visualizaciones (últimos 30 días)
Enrique Man
Enrique Man el 30 de Mzo. de 2018
Comentada: Walter Roberson el 4 de Dic. de 2024
I'm trying to write an equation with e, but I assume it would just take it as an undeclared variable.

Respuesta aceptada

Star Strider
Star Strider el 30 de Mzo. de 2018
You may want the exponential function exp (link), the base of the natural logarithms.
  3 comentarios
Steven Lord
Steven Lord el 3 de Dic. de 2024
Yes, though if you're planning to use it in expressions of the form e^t, instead of computing e separately then raising it to the power t I recommend calling exp with t as an input.
format longg
e = exp(1)
e =
2.71828182845905
y1 = e^2
y1 =
7.38905609893065
y2 = exp(2)
y2 =
7.38905609893065
Walter Roberson
Walter Roberson el 4 de Dic. de 2024
As an example of the difference between exp(1)^n and exp(n) :
format long g
e = exp(1);
y1 = e^20; fprintf('%.999g\n', y1);
485165195.409789741039276123046875
y2 = exp(20); fprintf('%.999g\n', y2);
485165195.4097902774810791015625
y1 - y2
ans =
-5.36441802978516e-07

Iniciar sesión para comentar.

Más respuestas (2)

Steven Lord
Steven Lord el 30 de Mzo. de 2018
Use the exp function.

Ephendy Sithole
Ephendy Sithole el 29 de Mayo de 2021
exp

Categorías

Más información sobre Entering Commands en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by