How to integrate a function inside the for loop ?
이전 댓글 표시
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)

채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Calculus에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


