Highlight Specific Portion of Graph

조회 수: 11 (최근 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 CenterFile Exchange에서 Specifying 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