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

조회 수: 11 (최근 30일)
THT
THT 2022년 1월 4일
답변: KSSV 2022년 1월 4일
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?

채택된 답변

KSSV
KSSV 2022년 1월 4일
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));

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by