MATLAB: Matrix multiplication for “3-D” matrices

matrix multiplication

i have 8 vectors a11, a12, a21, a22 and b11, b12, b21, b22 let's say of length 1×100. i want to do a*b matrix multiplication for the 2×2 matrices [a11 a12; a21 a22] and [b11 b12; b21 b22] and along the dimension of length 100. how to code this without using do loops?

Best Answer

result=nan(2,2,100);
result(1,1,:)=a11.*b11 + a12.*b21;
result(1,2,:)=a11.*b12 + a12.*b22;
result(2,1,:)=a21.*b11 + a22.*b21;
result(2,2,:)=a21.*b12 + a22.*b22;
Related Question