How to define a function in correct form and plot it out?
11 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
KSSV
on 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));
0 Comments
More Answers (0)
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!