How to integrate a function inside the for loop ?
Show older comments
I am trying to do integration inside a for loop. I am having problem with the matrix dimension or syntax maybe. Would anyone please help me fix it. Also It would like to plot the result of the integration.
clc
close all
clear all
Fs= 2.16*10^-5*pi; % Geometrical Factor for sun
Fa=pi; % Geometrical Factor for earth
Q=1.6*10^-16; % Electronic Charge
h= 4.136*10^-15; % Plancks Constant
c= 3*10^8; % Speed of light
K = 8.61*10^-5; % Boltzmanns Constant
Ts=5760; % Temparature of the sun
Ta=300; % Ambient Temparature
Eg=1.6; % BandGap Energy
A=((2*Fs)/(h^3*c^2));
B=(K*Ts);
C=((2*Fa)/(h^3*c^2));
D=(K*Ta);
vdata=0:0.01:1.6;
n=length(vdata);
q=zeros(1,n);
for i=1:n
V=vdata(i);
fun=@(E)((q.*E.^2).*((A/(exp(E./B)-1))-(C/(exp(E-(Q.*V))./B)-1)-(C/(exp(E./D)-1))));
q(i)=integral(fun,Eg,inf);
end
plot(V,q)

Accepted Answer
More Answers (0)
Categories
Find more on Calculus in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

