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

11 visualizaciones (últimos 30 días)
THT
THT el 4 de En. de 2022
Respondida: KSSV el 4 de En. de 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?

Respuesta aceptada

KSSV
KSSV el 4 de En. de 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));

Más respuestas (0)

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by