What do the constants h,c and k do to the function??

5 visualizaciones (últimos 30 días)
Britney
Britney el 16 de Oct. de 2014
Comentada: Britney el 16 de Oct. de 2014
figure('Name','Black Body','Menu','none','NumberTitle','on','Position',[500 100 350 450])
set(gcf,'Color',[0.6 1.0 1.0])
%h=6.6256e-34; c=2.9979e8; k=1.3805e-23;
u=@(lambda,T)(8*pi*h*c)./(lambda.^5.*(exp((h*c)./(k*lambda*T))-1));
%h=6.6256e-34; c=2.9979e8; k=1.3805e-23;
lambda=linspace(0.01e-6,10e-6,300);
plot(lambda*1e6,u(lambda, 800),'Color',[0.6 0.0 0.6],'LineWidth',2), hold on
plot(lambda*1e6,u(lambda, 850),'Color',[0.3 0.7 1.0],'LineWidth',2)
plot(lambda*1e6,u(lambda, 900),'Color',[0.0 0.8 0.0],'LineWidth',2)
plot(lambda*1e6,u(lambda, 950),'Color',[1.0 0.7 0.4],'LineWidth',2)
plot(lambda*1e6,u(lambda,1000),'Color',[0.9 0.0 0.0],'LineWidth',2), hold off
axis([0 10 0 200]), grid on
set(gca,'XTick',0:2:10,'YTick',0:50:200)
xlabel('Wavelength (\mum)','FontSize',11)
ylabel('Energy density (J m^{-4})','FontSize',11)
legend(' 800 K',' 850 K',' 900 K',' 950 K','1000 K')
If I have them before or after the anonymous function the graph works. If I take them away the graph still works.If I change say k to 1 no lines appear...which is odd since taking away all three values makes the graph work....I'm confused. Can anyone guide me in this?
The constants are c=speed of light, h=Pl*ncks const*nt and k=Boltzm*n const*nt.
  1 comentario
Britney
Britney el 16 de Oct. de 2014
Is it important if you put them before the function or after?? For me it works either way.
Take away the % guys from the constants. Sorry for the typo....I was trying what would happen if i put the constants after the function.

Iniciar sesión para comentar.

Respuesta aceptada

Star Strider
Star Strider el 16 de Oct. de 2014
The function picks up the constants from the workspace, so they have to appear in your code before the function. Defining the constants only after the function throws an error when I run it.
  4 comentarios
Star Strider
Star Strider el 16 de Oct. de 2014
The ‘u’ function is an anonymous function. The arguments and the variables they refer to in ‘u’ are ‘local’ to ‘u’ and are not shared by the rest of the workspace. It doesn’t matter what you call the various arguments to a function providing you change all references to those arguments in the function to match. (Note that while an anonymous function can pick up values of constants from the workspace, it does not share its internal variables with the workspace, returning as output to the workspace only the results of its calculations that you choose to have it return.)
Britney
Britney el 16 de Oct. de 2014
Thank you!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Graphics Object Properties 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