Effacer les filtres
Effacer les filtres

How to perform integration of product of multiple function inside a for loop?

1 vue (au cours des 30 derniers jours)
Hello everyone, I am having some troube integrating insiide a for loop. I am providing the code below. The code works wiithout the integration part when is not inside a loop. I am having Undefined operator '*' for input arguments of type 'function_handle' error. Can anyone fix my problem. It will be a great help and learning opportunity.
clc
clear all
close all
Fs= 2.16*10^-5*pi; % Geometrical Factor for sun
h= 4.136*10^-15; % Plancks Constant
c= 3*10^8; % Speed of light
k = 8.6173*10^-5; % Boltzmanns Constant
Ts=5760; % Temparature of the sun
q=1.6*10^-19; % electronic charge
T=300; % ambient temparature
beta=7.021*10^-4;
gamma=1108;
Eg0_1=1.1557;
Eg0_2=2.5;
Egd0=3.2;
Eg1=Eg0_1-((beta*(T^2))/(T+gamma));
Eg2=Eg0_2-((beta*(T^2))/(T+gamma));
Egd=Egd0-((beta*(T^2))/(T+gamma));
Ep1=1.827*10^-2;
Ep2=5.773*10^-2;
C1=5.5;
C2=4.0;
A1=3.231*10^2;
A2=7.237*10^3;
Ad=1.052*10^6;
A=((2*Fs)/((h^3)*(c^2)));
lambda_min=200*10^-9;
lambda_max= 1200*10^-9;
depth=0.1:0.01:5;
num=numel(depth);
G_t=nan(1,num);
for a=1:num
x=depth(a);
Photon_flux=@(lambda)((A*((((h*c)/lambda)^2)/(exp((((h*c)/lambda)/(k*Ts)))-1)))*q);
Alpha= @(lambda)((((C1*A1)*(((((h*c)/lambda)-Eg1+Ep1)^2)/(exp(Ep1/(k*T))-1)))+((C1*A1)*(((((h*c)/lambda)-Eg1-Ep1)^2)/(1-exp(-Ep1/(k*T)))))+(Ad*((((h*c)/lambda)-Egd)^(1/2))))*(10^-4));
Generation_Rate=@(lambda)(Photon_flux*Alpha*exp(-Alpha*x));
G_t(a)=integral(Generation_Rate,lambda_min,lambda_max);
end
plot(depth,G_t)
xlabel('depth \microm'),ylabel('Total Generation Rate')

Réponse acceptée

Torsten
Torsten le 1 Mar 2022
for a=1:num
x=depth(a);
Photon_flux=@(lambda)((A*((((h*c)/lambda)^2)/(exp((((h*c)/lambda)/(k*Ts)))-1)))*q);
Alpha= @(lambda)((((C1*A1)*(((((h*c)/lambda)-Eg1+Ep1)^2)/(exp(Ep1/(k*T))-1)))+((C1*A1)*(((((h*c)/lambda)-Eg1-Ep1)^2)/(1-exp(-Ep1/(k*T)))))+(Ad*((((h*c)/lambda)-Egd)^(1/2))))*(10^-4));
Generation_Rate=@(lambda)(Photon_flux(lambda)*Alpha(lambda)*exp(-Alpha(lambda)*x));
G_t(a)=integral(Generation_Rate,lambda_min,lambda_max,'ArrayValued',true);
end

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by