Nested Numerical Integration with multivariable functions
Ältere Kommentare anzeigen
I am attempting to evaluate a nested integral in matlab. The equation comes from a paper I am reading and is a weighting function used within another integral. The weighting function I am trying to numerically calculate is the following:

The variables D,d, and L are constant. I tried symbolic integration, beginning with the inner integral, but the code does not perform the integration. Only returning the input with the integration bounds. I started looking into numerical integration but the trapz() function doesnt work well with symbols. My code is shown below. And of course this code doesnt work, but the other methods I have tried dont either. Is there a way to alter this code to work for me? Any suggestions?
clear;clc;
d=.01; %1/e patch diameter;
D=.35; %Aperture Diameter
L=7e3; %Propagation distance;
N=30; %number of terms in the numerical integration
delta_theta=.1; %[rad] angular separation between 2 patches. At L=7000m .1 rad is 70cm. (Like the width of a window)
syms x u theta z delta
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%Calculate the 1st term
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Define the coefficients
coeff=-11.64*(16/pi)^2*D^(-1/3);
%Define the 1st integrand
f1=x*exp(-2*x^2);
%Define the 3rd integrand
f3=((u*acos(u))-u^2*(3-2*u^2)*sqrt(1-u^2))*(u^2*(1-z/L)^2+(z*d*x/(D*L))^2+2*u*(1-z/L)*...
(z*d*x/(D*L))*cos(theta))^(5/6);
u_values=linspace(0,1,N);
inner=zeros(1, N);
for i=1:N
inner_integral=subs(f3,u,u_values(i));
inner(i)=inner_integral;
end
inner=trapz(u_values,inner);
%Evaluate the middle integral numerically
theta_values=linspace(0,2*pi,N);
middle=zeros(1, N);
for j=1:N
middle_integral=subs(inner(j),theta,theta_values(j));
middle(i)=middle_integral;
end
middle=trapz(theta_values,middle);
%Evaluate the outer integral numerically
x_values=linspace(0,10000,N);
outer=zeros(1, N);
for j=1:N
outer_integral=subs(f1*inner(j),x,x_values(j));
outer(i)=outer_integral;
end
outer=trapz(x_values,outer);
first_term=coeff*outer;
1 Kommentar
Torsten
am 23 Aug. 2023
Use integral3.
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Numerical Integration and Differentiation finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
