필터 지우기
필터 지우기

I need help integrating this function

조회 수: 2 (최근 30일)
Ambali Odebowale
Ambali Odebowale 2022년 11월 8일
댓글: Ambali Odebowale 2022년 11월 8일
Below is the code. I got error when I tried to integrate Q_total. Below is the error i got
ERROR:
Index exceeds the number of array elements (202).
Error in main (line 95)
Q_total=integral(qtot(w(a)),0,w);
CODE:
for a=1:length(w)
betaevanmax=10/d; %upper limit of the parallel wavevector for evanescent wave integration (see ACS NANO paper method section)
betaevanmin=w(a)/c; %lower limit
%Finding spectral RHF for prop and evan fields
qevan_p(a)=(Theta(w(a), T1,0)-Theta(w(a), T2, V))*1/pi^2*integral(@(beta)sevan_p(w(a),beta, d),betaevanmin,betaevanmax,'Reltol',1E-6,'AbsTol',1E-10); %default abstol = 1E-10 reltol 1E-6
qevan_s(a)=(Theta(w(a), T1,0)-Theta(w(a), T2, V))*1/pi^2*integral(@(beta)sevan_s(w(a),beta, d),betaevanmin,betaevanmax,'Reltol',1E-6,'AbsTol',1E-10);
qprop_p(a)=(Theta(w(a), T1,0)-Theta(w(a), T2, V)).*1/pi^2.*integral(@(beta)(sprop_p(w(a),beta,d)),0,w(a)/c);
qprop_s(a)=(Theta(w(a), T1,0)-Theta(w(a), T2, V)).*1/pi^2.*integral(@(beta)(sprop_s(w(a),beta,d)),0,w(a)/c);
a/length(w)% progress indicator
end
qtot=qevan_p+qevan_s+qprop_p+qprop_s; %total intensity spectum
qtot=qtot*1.5193E15/10000; %in w/cm2/eV
qprop=(qprop_p+qprop_s)*1.5193E15/10000; %prop waves only, in w/cm2/eV
qevan=(qevan_p+qevan_s)*1.5193E15/10000; %evan waves only, in w/cm2/eV
bb=blackb(w,T1)*1.5193E15/10000; %in w/cm2/eV
%Spectral efficiency calculation
Q_total=integral(qtot(w(a)),0,w);

채택된 답변

Torsten
Torsten 2022년 11월 8일
The first argument to "integral" has to be a function or a function handle. Both does not seem to be the case in the call
Q_total=integral(qtot(w(a)),0,w);
If qtot is given as an array of values defined at the values of the vector w, maybe
Q_total = trapz(w,qtot)
is what you want.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Spectral Measurements에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by