How do you properly type 1/e^x in matlab?

5 ビュー (過去 30 日間)
Connor Lance
Connor Lance 2022 年 2 月 5 日
回答済み: Walter Roberson 2022 年 2 月 5 日
So I'm trying to get this formula to work but it seems the division before the e is causing issues, I've tried everthing I could think of but nothing clicks, is there any way to get 1/e^x to work in matlab?
clc
c=3*10^8; %speed of light (m/s)
h=6.626*10^-23; %Planck constant (J-s)
k=1.38*10^-23; %Boltzmann constant (J/K)
l=(0.1:0.1:3); %wavelength
t1=3000; % temperature (K)
R=((2*pi*c^2*h)./l).*(1/(exp((h*c)/(l.*k*t1))-1))
Error using /
Matrix dimensions must agree.

採用された回答

VBBV
VBBV 2022 年 2 月 5 日
clc
c=3*10^8; %speed of light (m/s)
h=6.626*10^-23; %Planck constant (J-s)
k=1.38*10^-23; %Boltzmann constant (J/K)
l=(0.1:0.1:3); %wavelength
t1=3000; % temperature (K)
R=((2*pi*c^2*h)./l).*(1./(exp((h*c)./(l.*k*t1))-1))
Use element wise division

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2022 年 2 月 5 日
For 1/e^x you could use 1./exp(x) but more often it is better to use exp(-x)

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by