How do I plot an integral which is repeated over an interval?
I am attempting to plot the absporptance (alpha_s_bar) of an uncontaminated spacecraft as a function of the incident light wavelenght. The absorptance is found by integrating two different functions of wavelength over an interval from zero to the wavelength value of interest, on an interval from 0 to 0.7 microns. The code I have attached below runs and returns different values of absorptance as the wavelenght of interest (L) changes, but does not save the values before iterating, so I end up with one scalar value as alpha_s_bar. I am interested in saving the values of alpha_s_bar as a vector so I can plot them against the wavelength.
%Note that I will be using x for the wavelength for ease of typing
% Start by defining the constants for the absorptance for typical
% outgassing products, called alpha_c in problem statement, where
% alpha_c=M10*exp(M11*L)
M10=34.898;
M11=-8.6481;
% Next define the constants for solar absorptivity, alpha_s, where
% aplha_s=M0+M1*L+M2*L^2+M3*L^3
M0=0.28779;
M1=0.06028;
M2=-0.046055;
M3=0.020211;
% Next, define the constants for the solar spectrum (adjusted so units are microns), S, where
% S=2*C1/L^5[exp(C2/L*T)-1]
T=5500;
C1=5.594E-7;
C2=1438.8;
for L=0:0.01:0.7;
fnum=@(x) (M0+M1.*x+M2.*(x.^2)+M3.*(x.^3))./((x.^5).*exp(C2./(x.*T)));
fden=@(x) 1./((x.^5).*exp(C2./(x.*T)));
alpha_bar_s=integral(fnum,0,L)./integral(fden,0,L)
plot(L,alpha_bar_s)
hold on
endI am attempting to plot the absporptance (alpha_s_bar) of an uncontaminated spacecraft as a function of the incident light wavelenght. The absorptance is found by integrating two different functions of wavelength over an interval from zero to the wavelength value of interest, on an interval from 0 to 0.7 microns. The code I have attached below runs and returns different values of absorptance as the wavelenght of interest (L) changes, but does not save the values before iterating, so I end up with one scalar value as alpha_s_bar. I am interested in saving the values of alpha_s_bar as a vector so I can plot them against the wavelength.
%Note that I will be using x for the wavelength for ease of typing
% Start by defining the constants for the absorptance for typical
% outgassing products, called alpha_c in problem statement, where
% alpha_c=M10*exp(M11*L)
M10=34.898;
M11=-8.6481;
% Next define the constants for solar absorptivity, alpha_s, where
% aplha_s=M0+M1*L+M2*L^2+M3*L^3
M0=0.28779;
M1=0.06028;
M2=-0.046055;
M3=0.020211;
% Next, define the constants for the solar spectrum (adjusted so units are microns), S, where
% S=2*C1/L^5[exp(C2/L*T)-1]
T=5500;
C1=5.594E-7;
C2=1438.8;
for L=0:0.01:0.7;
fnum=@(x) (M0+M1.*x+M2.*(x.^2)+M3.*(x.^3))./((x.^5).*exp(C2./(x.*T)));
fden=@(x) 1./((x.^5).*exp(C2./(x.*T)));
alpha_bar_s=integral(fnum,0,L)./integral(fden,0,L)
plot(L,alpha_bar_s)
hold on
end I am attempting to plot the absporptance (alpha_s_bar) of an uncontaminated spacecraft as a function of the incident light wavelenght. The absorptance is found by integrating two different functions of wavelength over an interval from zero to the wavelength value of interest, on an interval from 0 to 0.7 microns. The code I have attached below runs and returns different values of absorptance as the wavelenght of interest (L) changes, but does not save the values before iterating, so I end up with one scalar value as alpha_s_bar. I am interested in saving the values of alpha_s_bar as a vector so I can plot them against the wavelength.
%Note that I will be using x for the wavelength for ease of typing
% Start by defining the constants for the absorptance for typical
% outgassing products, called alpha_c in problem statement, where
% alpha_c=M10*exp(M11*L)
M10=34.898;
M11=-8.6481;
% Next define the constants for solar absorptivity, alpha_s, where
% aplha_s=M0+M1*L+M2*L^2+M3*L^3
M0=0.28779;
M1=0.06028;
M2=-0.046055;
M3=0.020211;
% Next, define the constants for the solar spectrum (adjusted so units are microns), S, where
% S=2*C1/L^5[exp(C2/L*T)-1]
T=5500;
C1=5.594E-7;
C2=1438.8;
for L=0:0.01:0.7;
fnum=@(x) (M0+M1.*x+M2.*(x.^2)+M3.*(x.^3))./((x.^5).*exp(C2./(x.*T)));
fden=@(x) 1./((x.^5).*exp(C2./(x.*T)));
alpha_bar_s=integral(fnum,0,L)./integral(fden,0,L)
plot(L,alpha_bar_s)
hold on
end matlab, integral, plotting, for loop MATLAB Answers — New Questions