I'm trying to write an equation with e, but I assume it would just take it as an undeclared variable.

 채택된 답변

Star Strider
Star Strider 2018년 3월 30일

4 개 추천

You may want the exponential function exp (link), the base of the natural logarithms.

댓글 수: 3

So I guess the answer to the question would be:
e = exp(1) % Euler's number
e = 2.7183
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
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

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

카테고리

도움말 센터File Exchange에서 Parallel Computing Toolbox에 대해 자세히 알아보기

태그

질문:

2018년 3월 30일

댓글:

2024년 12월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by