Function handle: intergal of another integral
Show older comments
Good morning everyone, I'm trying to solve a quadruple integral with the function handle. The problem is that between them there is a double integral on a domain R. so I decided to first solve the integrals on the domain R and then integrate the result with respect to the other two variables but I have some trouble.
I know that I could solve symbolically but the "intpoly" function only works with "function handle";
my code is:
mi=[1:2:100]' %where mi, xi, yi are arrays with same length.
xi=[1:3:150]'
yi=[1:4:200]'
B=1.09*log(10) %costant value
fun=@(t,m,x,y) ((B./(t-1943)).*exp(-B.*(m-5.75))).*sum((mi(1:50)-5.75).*(1/pi).*(1./(((x-(xi(1:50)).^2+(y-yi(1:50).^2))))))
t1=1965
t2=2000
m1=5.75
m2=8
G=@(T,M,X,Y) arrayfun(fun,T,M,X,Y)
F=integralN(G,t1,t2,m1,m2,174,180,-35,-41) %if I solve the integralN (not considering the polygon R) there are no mistakes
F2=integral2(@(T,M) intpoly(@(X,Y) G(T,M,X,Y), [177.63,182.17,178.7,175.55,177.63],[-37,-37,-40.87,-39.3,-37]),t1,t2,m1,m2)
%if i solve this last matlab gives me the sequent errors:
Error using arrayfun
All of the input arguments must be of the same size and shape.
Previous inputs had size 14 in dimension 1. Input #4 has size 2
Error in INTEGRALE_SUL_DOMINIO>@(T,M,X,Y)arrayfun(fun,T,M,X,Y)
Error in INTEGRALE_SUL_DOMINIO>@(X,Y)G(T,M,X,Y)
Error in integral2Calc>integral2t/tensor (line 237)
Z1 = FUN(X(VTSTIDX),Y(VTSTIDX)); 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 intpoly (line 40)
z=integral2(f,xmin,xmax,ymin,ymax);
Error in
INTEGRALE_SUL_DOMINIO>@(T,M)intpoly(@(X,Y)G(T,M,X,Y),[177.63,182.17,178.7,175.55,177.63],[-37,-37,-40.87,-39.3,-37])
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 INTEGRALE_SUL_DOMINIO (line 13)
F2=integral2(@(T,M) intpoly(@(X,Y) G(T,M,X,Y), [177.63,182.17,178.7,175.55,177.63],[-37,-37,-40.87,-39.3,-37]),t1,t2,m1,m2)
>>Thanks for your help!
Answers (0)
Categories
Find more on Symbolic Math Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!