MATLAB: Double integral of matrix

double integralMATLABmatrices

Hi! can someone kindly help me out with this code?
t = 1;
b = 10;
h = 5;
Bmat = @(x,y) (1./(4.*b.*h)).*[-(h-y), 0, (h-y), 0, (h+y), 0, -(h+y), 0;0, -(b-x), 0, -(b+x), 0, (b+x), 0, (b-x);-(b-x), -(h-y), -(b+x), (h-y), (b+x), (h+y), (b-x), -(h+y)];
Bmat_T = @(x,y) (1./(4.*b.*h)).*[-(h-y), 0, -(b-x);0, -(b-x), -(h-y);(h-y), 0, -(b+x);0, -(b+x), (h-y);(h+y), 0, (b+x);0, (b+x), (h+y);-(h+y), 0, (b-x);0, (b-x), -(h+y)];
v = 0.3;
YoungM = 30.*10.^6;
Dmat = (YoungM./(1-v.^2))*[1 v 0;v 1 0;0 0 ((1-v)./2)]
Kmat = integral2(@(x,y)(Bmat_T(x,y).*Dmat.*Bmat(x,y).*t), -b, b, -h, h)
This is the error I get…
Error using horzcat
Dimensions of arrays being concatenated are not consistent.
Error in
HW6_P4>@(x,y)(1./(4.*b.*h)).*[-(h-y),0,-(b-x);0,-(b-x),-(h-y);(h-y),0,-(b+x);0,-(b+x),(h-y);(h+y),0,(b+x);0,(b+x),(h+y);-(h+y),0,(b-x);0,(b-x),-(h+y)]
Error in HW6_P4>@(x,y)(Bmat_T(x,y).*Dmat.*Bmat(x,y).*t)
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 HW6_P4 (line 19)
Kmat = integral2(@(x,y)(Bmat_T(x,y).*Dmat.*Bmat(x,y).*t), -b, b, -h, h)

Best Answer

Since you are trying to integrate a matrix equation. You will need to make two calls to integral() with ArrayValued option enabled
Kmat = integral(@(x) integral(@(y) (Bmat_T(x,y)*Dmat*Bmat(x,y).*t), -h, h, 'ArrayValued', 1), -b, b, 'ArrayValued', 1);
Related Question