How to shade area under curve between x values

3 次查看(过去 30 天)
I can't get the area to fill between the dimensions quite right, it keeps shaping wrong area, so far i have this code below
close
clear
clc
r_d = 1.50e11; % distance from Earth to Sun
r_s = (1.39e9)/2; % radius of the sun
fw =(r_s/r_d)^2;
t_s = 5800; % temp in kelvin
h = 6.626e-34; % in J*s
k_b = 1.381e-23; % in J/K
c = 2.998e8; % in m/s
syms lambda L_sun
lambda = (0.001:0.01:3)*1e-6;
L_sun = fw .* (2*pi*h*c.^2) ./ lambda.^5 .*...
1./(exp((h*c)./(lambda*k_b*t_s)) -1);
figure(1)
plot(lambda, L_sun, 'b-', 'LineWidth', 2);
xlim([0 3e-6]);
xlabel('Wavelength (um)');
ylabel('Spectral Irradiance (W*m^2/m^-1)');
legend('L_s_u_n')
set(gcf, 'PaperPositionMode', 'manual');
set(gcf, 'PaperUnits', 'inches');
set(gcf, 'PaperPosition', [0 0 6.75 5]);
print('SolarIrradiance.tif', '-dpng', '-r600')
saveas(gcf, 'SolarIrradiance.fig')
%%
% Part 2.
maxL_sun = max(L_sun);
lambda_max = lambda(51);
% i. this falls in the visible region
% ii. uv = 6.4%, vis = 48%, and ir = 45.6%
% the energy for uv = 87, vis = 565, and ir = 623
UV = L_sun(1:38);
Vis = L_sun(39:78);
IR = L_sun(79:300);
UV_Vis_IR_fig = openfig('SolarIrradiance.fig');
hold on
and i need to shade the UV, Vis, and IR regions of a previously made graph and save it as a new one

采纳的回答

Image Analyst
Image Analyst 2019-12-14
Try using area() to plot instead of plot().

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by