Asked by Jack Dempsey
on 16 Jan 2013

I'm trying to create a surface plot of the Plack radiation law over a range of temperatures and wavelengths, but when so far I've been unsuccessful. I've tried to use meshgrid to set my range of values as

EDU>> [l,T] = meshgrid(0:25:1000,0:300:12000);

where l is wavelength in nm and T is temperature in Kelvins. However, this means that when I plug it into my energy distribution function, I get a matrix filled with the same row.

distr = Planck(l,T);

where Planck is the function defined by

function [ distr ] = Planck( lam,temp )

%Applies the Planck radiation law to give the energy emitted by a black

%body for some given wavelength and temperature. Units are dimensionless,

%and given by u(lamda,T)/(8*pi*c*h/((550nm)^5).

% Input:

%lam = the actual wavelength

%temp = the actual temperature

%For our reference wavelength, we will use 550 nm, meaning that our

%reference temperature will be 26180 in accordance with the relationship

%T-knot = (h*c)/(lambda-knot*k)

L = lam/(550);

T = temp/(26180);

e = exp(1);

distr = (1./(L.^5))./(e.^(1./(L*T))-1);

end

Having used this to create a number of 2-D plots, the 3-D version should have lower z values for lower temperatures, but because all of the rows of distr are the same, the function is being displayed as constant with respect to T. So if I have a range of x values and a range of y values, and z is a function of x and y, how do I create a matrix filled with z-values for each combination of x and y in that range?

*No products are associated with this question.*

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi test

Learn moreOpportunities for recent engineering grads.

Apply Today
## 4 Comments

## Jan Simon (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/58887#comment_122888

Please format your code properly. Thanks.

## Jack Dempsey (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/58887#comment_123463

Could you please be a little bit more specific in your criticism? For future reference, what exactly should I be aware of?

## Cedric Wannaz (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/58887#comment_123471

Was note your code per se I guess but your post. Just by adding a few spaces on lines starting with code and using

||to make e.g. variable names standing out in chunks of text, you would have made it more readable:I'm trying to create a surface plot of ...

where

lis wavelength innmandTis temperature in Kelvins. However, this means that when I plug it into my energy distribution function, I get a matrix filled with the same row.where Planck is the function defined by

Having used this to create a number of 2-D plots, the 3-D version should have lower

zvalues for lower temperatures, but because all of the rows ofdistrare the same, the function is being displayed as constant with respect toT. So if I have a range ofxvalues and a range ofyvalues, andzis a function ofxandy, how do I create a matrix filled withz-values for each combination ofxandyin that range?## Jack Dempsey (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/58887#comment_123671

Alright, I'll keep that in mind. Thanks.