How do I make a 3d plot of black body radiation

I have attached the question and my current code. Not sure what is going wrong

1 Comment

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.

Sign in to comment.

 Accepted Answer

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:
  1. 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.).
  2. You are using / instead of ./, which means you are doing matrix division instead of element-by-element division.
  3. 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).
  4. You probably want to call mesh or surf instead of plot3.
  5. Check out logspace instead of linspace.

1 Comment

This really helped me and I got it now. This is my first post on this site, and I will make sure to make my next question here more convenient to read. Thank you.

Sign in to comment.

More Answers (1)

Categories

Find more on Mathematics in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!