How to define a function in correct form and plot it out?
조회 수: 11 (최근 30일)
이전 댓글 표시
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?
댓글 수: 0
채택된 답변
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
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
