How to define a function in correct form and plot it out?

10 Ansichten (letzte 30 Tage)
THT
THT am 4 Jan. 2022
Beantwortet: KSSV am 4 Jan. 2022
I want to plot the equation:
Here is my code and error messages:
T = linspace(0,1000,10);
u = @(k,T,h_,n,m) k*T.*log(exp(pi*h_*h_*n/(m*k*T))-1);
k = 1.38064852 * 10^-23;
h_ = 6.62607004 * 10^-34;
n = 10^15;
m = 9.10938356 * 10^-31;
plot(T,u(k,T,h_,n,m));
Error using /
Matrix dimensions must agree.
Error in Q_b>@(k,T,h_,n,m)k*T.*log(exp(pi*h_*h_*n/(m*k*T))-1) (line 3)
u = @(k,T,h_,n,m) k*T.*log(exp(pi*h_*h_*n/(m*k*T))-1);
Error in Q_b (line 20)
plot(T,u(k,T,h_,n,m));
I don't konw where goes wrong? How to make it right?

Akzeptierte Antwort

KSSV
KSSV am 4 Jan. 2022
Element by element division is needed. ./ should be used.
T = linspace(0,1000,10);
u = @(k,T,h_,n,m) k*T.*log(exp(pi*h_*h_*n./(m*k*T))-1);
k = 1.38064852 * 10^-23;
h_ = 6.62607004 * 10^-34;
n = 10^15;
m = 9.10938356 * 10^-31;
plot(T,u(k,T,h_,n,m));

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by