Parameter vectors outside integration function

1 次查看(过去 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 个评论

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Computations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by