How do I make a 3d plot of black body radiation
2 views (last 30 days)
Show older comments
Joseph Renteria
on 24 Jan 2018
Commented: Joseph Renteria
on 24 Jan 2018
I have attached the question and my current code. Not sure what is going wrong
1 Comment
Benjamin Kraus
on 24 Jan 2018
Edited: Benjamin Kraus
on 24 Jan 2018
In the future, it is much easier for people to help you if you copy/paste your code into the question (and indent it so you get the correct formatting). Reading it from an image makes it much harder to determine the problem, because I don't know if a bug is in my copying your code by hand, or a bug in your original code.
Accepted Answer
Benjamin Kraus
on 24 Jan 2018
Edited: Benjamin Kraus
on 24 Jan 2018
Assuming I typed it correctly, here is the code you provided:
C1(1:100) = 3.742*10^8;
C2(1:100) = 1.439*10^4;
Lambda = linspace(0.1,10,100);
t = linspace(100,2000,100);
[lambda,T] = meshgrid(Lambda,t);
E = C2/lambda.*(exp((C1/(lambda.*T)))-1);
plot3(lambda,T,E)
set(gca,'XScale','log')
I noticed a few problems. Here are some hints to help you along:
- You need to double-check your equation (check your order-of-operations with multiplication and division, you are missing some extra parentheses, you are missing an exponent, you have constants switched, etc.).
- You are using / instead of ./, which means you are doing matrix division instead of element-by-element division.
- You are defining C1 and C2 as vectors instead of either matrices or scalars. I think you actually want to define them using scalars (there is no need to define them as matrices if they are just constants).
- You probably want to call mesh or surf instead of plot3.
- Check out logspace instead of linspace.
More Answers (1)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!