MATLAB: How to multiply a (13*1) vector by a (13*13*1269) matrix

3dmatrix multiplication

I've created 1269 13*13 covariance matrices, and am now trying to multiply each 13*13 matrix by the both a 13*1 and 1*13 vector, so that I will end up with a 1269*1 vector. However I'm having trouble doing this.
A=13*1
B=1*13 (transpose of A)
C= 13*13*1269
Any help is much appreciated.

Best Answer

3D multiplications are not defined in Matlab, so I'm going to assume your intended output is something like this:
%initialize with random data
A=rand(13,1);B=A';
C=rand(13,13,1269);
%pre-allocate output and loop through the 3rd dimension
out=zeros(size(C,3),1);
for k=1:size(C,3)
out(k)=A*B*C(:,:,k);
end