MATLAB: I want to multiply a 400x300x61 matrix with a 61×61 matrix

matrix manipulation

I have matrices with following size: A=400x300x61; B=61×61; C=61×3;
I want to eventually perform a AxBxC multiplication. I tried with the following code
for i=1:61
Result(:,:,i)= A(:,:,i)*B*C;
end
It always gives some error, I have tried n number of changes in the code, tried to do it in two steps but to no avail.
Any help is appreciated.

Best Answer

Result = zeros(size(A, 1), size(A, 2), size(C, 2));
for row = 1:size(A, 1) %don't hardcode matrix size when you can just ask for it
Result(row, :, :) = squeeze(A(row, :, :)) * B * C;
end
may be what you are after.
Related Question