Highlight Specific Portion of Graph

14 ビュー (過去 30 日間)
Brittany Burns
Brittany Burns 2020 年 9 月 19 日
コメント済み: Star Strider 2020 年 9 月 19 日
I am trying to highlight the visible wavelength that would appear on the curve (0.4-0.7) in figure 2. How do I do this? I.e. I want to highlight the portion of the curve that falls under the wavelength from 0.4-0.7.
clear all; clc
%Since we are working with a blackbody, we assume n=1, which
%then allows us to use Stefan-Boltzmann's constant and law
n=1;
T=1300; %[Kelvin]
sigma = 5.67e-8; %Stefan-Boltzmann constant [W/(m^2*K^4)]
C1=0.59585522e8; %[W*micrometers^4/m^2*Sr]
C2=14357.770; %[micrometer*K]
%Spectral Intensity
lambda=10e-2:0.1:10e2; %[micrometers]
I=(2*C1)./(n^2.*lambda.^5.*(exp(C2./(n.*lambda.*T))-1));
clf;figure(1)
semilogx(lambda,I)
%Emissive Power
wl=10e-2:0.05:10e2;%[micrometers]
E=(2*C1*pi)./(n^2.*wl.^5.*(exp(C2./(n.*wl.*T))-1));
figure(2)
semilogx(wl,E)
hold on

採用された回答

Star Strider
Star Strider 2020 年 9 月 19 日
I am not ccertain what you want to highlight, since that region is vanishingly small.
Try this:
%Emissive Power
wl=10e-2:0.05:10e2;%[micrometers]
E=(2*C1*pi)./(n^2.*wl.^5.*(exp(C2./(n.*wl.*T))-1));
Lv = (wl >= 0.4) & (wl <= 0.7);
figure(2)
plot(wl,E)
hold on
patch([wl(Lv) fliplr(wl(Lv))], [zeros(size(E(Lv))) fliplr(E(Lv))], 'r')
hold off
set(gca, 'XScale','log')
ylim([0 200])
figure(3)
plot(wl,E)
hold on
patch([wl(Lv) fliplr(wl(Lv))], [zeros(size(E(Lv))) ones(1,nnz(Lv))*max(ylim)], 'r', 'FaceAlpha',0.25)
hold off
set(gca, 'XScale','log')
ylim([0 200])
The first plot colourss the area under the curve, and the second plot highlights the entire region to the limits of the y-axis.
I restricted the y-axis limit in order to see the area of interest. With the normal limits, it iis simply not visible.
  2 件のコメント
Brittany Burns
Brittany Burns 2020 年 9 月 19 日
Thanks!
Star Strider
Star Strider 2020 年 9 月 19 日
As always, my pleasure!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpecifying Target for Graphics Output についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by