I need help integrating this function

3 ビュー (過去 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.
  1 件のコメント
Ambali Odebowale
Ambali Odebowale 2022 年 11 月 8 日
This works!!! Thanks so much

サインインしてコメントする。

その他の回答 (0 件)

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by