Calculating double integral of two variable
조회 수: 33 (최근 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!