Calculating double integral of two variable
30 次查看(过去 30 天)
显示 更早的评论
I am having some issues calculation a double integral with two variable. my function F= {{sinc^2(X)sinc^2(Y)} *{sin^2(phi)+cos^2(theta)cos^2(phi)}}(sin(theta)).
I define X=(pi/2).*sin(theta).*cos(phi) and Y=(pi/2).*sin(theta).*sin(phi); and theta=[0 pi/2]; phi=[0 2*pi].
So, I have started
syms X Y theta phi
theta=linspace(0,pi/2);
phi=linspace(0,2*pi);
X=(pi/2).*sin(theta).*cos(phi);
Y=(pi/2).*sin(theta).*sin(phi);
func1=(sinc(X/pi).*sinc(Y/pi)).^2;
func2={(sin(theta))^2}+{cos(theta)cos(phi)}^2;
func=func1*func2;
func3=sin(theta);
Function1=vpa(int(func,0,2*pi),5)*vpa(int(func3,0,pi/2),5)
But I have also tried to rewrite
syms X Y theta phi
X=(pi/2).*sin(theta).*cos(phi);
Y=(pi/2).*sin(theta).*sin(phi);
Function1=@(theta,phi) ((sinc(X/pi).*sinc(Y/pi))^2 *((sin(phi))^2+(cos(theta)*cos(phi))^2))*(sin(theta));
E=integral2(Function1,0,pi/2,0,2*pi)
0 个评论
回答(1 个)
Devineni Aslesha
2020-6-22
编辑:Devineni Aslesha
2020-6-22
Hi Ismael,
To calculate the double integral of a two variable function, integral2 accepts only numeric variables. So, the entire function with two variable is defined as a single inline executable expression (anonymous function handles) as shown below.
Function1 = @(theta,phi) (((sinc((pi/2).*sin(theta).*cos(phi)).*sinc((pi/2).*sin(theta).*sin(phi))).^2).*((sin(phi)).^2+(cos(theta).*cos(phi)).^2)).*(sin(theta));
E = integral2(Function1,0,pi/2,0,2*pi)
For more information, refer the following link
2 个评论
madhan ravi
2020-6-22
The first statement contradicts the fact that int(...) with two calls exist if there’s an explicit solution.
Devineni Aslesha
2020-6-22
编辑:Devineni Aslesha
2020-6-22
int can accept both numeric and symbolic variables, whereas integral2 accepts only numeric variables as integral2 solves the integral numerically. Also, thanks for pointing that out, I can edit the answer specific to integral2.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!