how to make anonymous function and it's plot?
8 次查看(过去 30 天)
显示 更早的评论
i want to make black body radiation
clear
close all
clc
%Black body radiation graph
R=@(wl,T) 2*pi*c^2*h./(wl.^5)./(exp(h*c./wl/k/T)-1);
h=6.626e-34;
c=3e8;
k=1.38e-23;
wl=0.1:0.1:3;
this is my code but they said c doesn't recognize what's the problem...?
0 个评论
回答(1 个)
Star Strider
2020-11-21
Either include all of them as arguments:
R=@(wl,T,h,c,k) 2*pi*c^2*h./(wl.^5)./(exp(h*c./wl/k/T)-1);
h=6.626e-34;
c=3e8;
k=1.38e-23;
wl=1E-9:0.1:3;
T = 273;
figure
plot(wl,R(wl,T,h,c,k) )
grid
or define the ‘R’ function after assigning the constants:
%Black body radiation graph
h=6.626e-34;
c=3e8;
k=1.38e-23;
R=@(wl,T) 2*pi*c^2*h./(wl.^5)./(exp(h*c./wl/k/T)-1);
wl=1E-9:0.1:3;
T = 273;
figure
plot(wl,R(wl,T))
grid
Regardless, the constants must exist in your workspace before the ‘R’ function is called.
Both of these will work.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!