Parameter vectors outside integration function

조회 수: 3 (최근 30일)
Saeid
Saeid 2017년 4월 30일
댓글: Star Strider 2017년 4월 30일
I am trying to calculate a double integral with three varibales in the form of a vector AB and another scalar B also as a paremeter. If I write the routine so that AB and B are inside the integration fucntion:
Inty3=integral2(@Func3,0,1,0,@(y) y)
function fy3 = Func3(z,y)
AB=[1 2 3];
BB=1;
fy0=sqrt((AB(1)*z+AB(2)).^2+(BB*z+AB(3)).^2);
fyy=((1+fy0).^2)./(1-fy0); % F(y) in Eq.17
fAy=(AB(1)*z+AB(2))./(1-fy0);
fy3=fyy.*fAy;
end
the integral is clauclated without a problem, but if AB and B are moved outside of Fun3, i.e.,
AB=[1 2 3];
BB=1;
Inty3=integral2(@Func3,0,1,0,@(y) y)
function fy3 = Func3(z,y)
fy0=sqrt((AB(1)*z+AB(2)).^2+(BB*z+AB(3)).^2);
fyy=((1+fy0).^2)./(1-fy0); % F(y) in Eq.17
fAy=(AB(1)*z+AB(2))./(1-fy0);
fy3=fyy.*fAy;
end
then I receive the following error message:
Not enough input arguments.
Error in DoubleInt>Func3 (line 15)
fy0=sqrt((AB(1)*z+AB(2)).^2+(BB*z+AB(3)).^2);
Error in integral2Calc>integral2t/tensor (line 228)
Z = FUN(X,Y); NFE = NFE + 1;
Error in integral2Calc>integral2t (line 55)
[Qsub,esub] = tensor(thetaL,thetaR,phiB,phiT);
Error in integral2Calc (line 9)
[q,errbnd] =
integral2t(fun,xmin,xmax,ymin,ymax,optionstruct);
Error in integral2 (line 106)
Q = integral2Calc(fun,xmin,xmax,yminfun,ymaxfun,opstruct);
Error in DoubleInt (line 10)
Inty3=integral2(@Func3,0,1,0,@(y) y)

채택된 답변

Star Strider
Star Strider 2017년 4월 30일
You need to change your call to ‘Func3’ in the second example:
Inty3=integral2(@(z,y) Func3(z,y,BB,AB),0,1,0,@(y) y)
  댓글 수: 4
Saeid
Saeid 2017년 4월 30일
Perfect, thanks!
Star Strider
Star Strider 2017년 4월 30일
My pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by