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

3 ビュー (過去 30 日間)
Joseph Renteria
Joseph Renteria 2018 年 1 月 24 日
コメント済み: Joseph Renteria 2018 年 1 月 24 日
I have attached the question and my current code. Not sure what is going wrong
  1 件のコメント
Benjamin Kraus
Benjamin Kraus 2018 年 1 月 24 日
編集済み: Benjamin Kraus 2018 年 1 月 24 日
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.

サインインしてコメントする。

採用された回答

Benjamin Kraus
Benjamin Kraus 2018 年 1 月 24 日
編集済み: Benjamin Kraus 2018 年 1 月 24 日
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 件のコメント
Joseph Renteria
Joseph Renteria 2018 年 1 月 24 日
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.

サインインしてコメントする。

その他の回答 (1 件)

Community Treasure Hunt

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

Start Hunting!

Translated by