Adding Color Under Certain Areas of Function Plot
Afficher commentaires plus anciens
I need to add color to certain areas under the plotted function but can not get anything I try to work. Help would be much appreciated.
This is what I have so far:
%% Part 1: Solar Radiation
%Constants:
h = 6.626e-34;
k = 1.381e-23;
c = 2.998e8;
t = 5800;
r_sun = 1.39e9/2;
r_earth = 1.5e11;
f_w = (r_sun/r_earth)^2;
%Function:
L_sun =@(l) f_w*((2*pi*h*c^2)./l.^5).*(1./(exp(h*c./(l*k*t))-1));
%Plotting Function:
figure(1)
fplot (L_sun, [0,3e-6],'LineWidth',2)
x0=10;
y0=10;
width=675;
height=500;
title('Solar Spectral Irradiance','fontsize',14)
ylabel('Spectral irradiance(W*m^-^2)','fontsize',14)
xlabel('Wavelegth(m)','fontsize',14)
axes('pos',[.4 .6 .5 .3])
%imshow('equation(1).png')
%% Part 2: Energy Distrubution
%I added below ths line when using the bounds use the nanometers since
% we are in meters everthing needs to be conveted.
l = [0:0.01e-6:3e-6];
X = f_w*((2*pi*h*c^2)./l.^5).*(1./(exp(h*c./(l*k*t))-1));
Max = max(X) %maximum irradiance
%Energy recieved by region:
UV = integral(L_sun,0,0.38e-6)
Vis = integral(L_sun,0.38e-6,0.78e-6)
IR = integral(L_sun,0.78e-6,3e-6)
This is the plot I currently have:

Below is what I am trying to accomplish:

Réponse acceptée
Plus de réponses (1)
Image Analyst
le 13 Déc 2019
0 votes
Try patch() or fill()
2 commentaires
Chase Valo
le 14 Déc 2019
Image Analyst
le 15 Déc 2019
Modifié(e) : Image Analyst
le 15 Déc 2019
Of course. Star Strider is passing in numbers. What were you trying to pass in? A character string???
Catégories
En savoir plus sur Color and Styling dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
