I need help integrating this function
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Ambali Odebowale
am 8 Nov. 2022
Kommentiert: Ambali Odebowale
am 8 Nov. 2022
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);
0 Kommentare
Akzeptierte Antwort
Torsten
am 8 Nov. 2022
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.
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!