Input array size error for a quadraple integration using nested integral2

2 views (last 30 days)
I need to perform a quadruple integration using integral2 function. The code is below:
Rb = @(rho_1,phi_1) rho_1.*cos(phi_1);
Sb = @(rho_2,phi_2) rho_2.*cos(phi_2);
Tb = @(rho_1,phi_1,rho_2,phi_2) rho_1.*cos(phi_1)-rho_2.*cos(phi_2);
InnerIntegrand = @(rho_1,phi_1,rho_2,phi_2) Rb(rho_1,phi_1).*Sb(rho_2,phi_2).*Tb(rho_1,phi_1,rho_2,phi_2);
InnerIntegral = @(rho_1,phi_1) integral2(@(rho_2,phi_2) InnerIntegrand(rho_1,phi_1,rho_2,phi_2),0,3,0,2*pi);
II = integral2(InnerIntegral,0,3,0,2*pi);
where InnerIntegrand (rho_1,phi_1,rho_2,phi_2) is the integrand. The InnerIntegral evaluates over rho_2 and phi_2, which is being called from an outer integral2 (integration over rho_1 and phi_1). But I obtain an error:
Error using .*
Matrix dimensions must agree.
Error in @(rho_1,phi_1,rho_2,phi_2)Rb(rho_1,phi_1).*Sb(rho_2,phi_2).*Tb(rho_1,phi_1,rho_2,phi_2)
Error in @(rho_2,phi_2)InnerIntegrand(rho_1,phi_1,rho_2,phi_2)
Error in integral2Calc>integral2t/tensor (line 238)
Z1 = FUN(X(VTSTIDX),Y(VTSTIDX)); NFE = NFE + 1;
Is the error come due to different array sizes of two integral2 calls? Could any one help me to figure and solve this issue?
Thanks in advance.
--Anoop

Answers (0)

Community Treasure Hunt

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

Start Hunting!