trapz Vs. quad - 1 integral 2 different results
Show older comments
Hi every one,
I'm trying to find a numeric solve for an integral, and got some weird answer.
so i tried with another function and got a different answer.
i suppose one of them is the right answer, my bet is the trapz answer is the right one. but I'm not sure.
can somebody explain where i am wrong? next thing i need to solve an 2d-integral using quad2d, and i have to know how to do it right.
10x
here is a running code:
clear
Fi1=@(ro,z,theta1,k)exp(k.*z.*cos(theta1).*1i).*sqrt(cos(theta1)).* sin(theta1).^2.*besselj(1.0,k.*ro.*sin(theta1));
NA=0.95;
ni=1;
alpha=asind(NA/ni)
alpha=asin(NA/ni);
lambda=600e-9;
r=0.5e-6;
z=0;
V=linspace(0,alpha,300);
k=2*pi/lambda;
I1_1=trapz( Fi1(r,z,V,k), V)
I1_2=quad( @(theta1) Fi1(r,z,theta1,k), 0,alpha)
Accepted Answer
More Answers (0)
Categories
Find more on Numerical Integration and Differentiation 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!