MATLAB: Command for perfect matrix multiplication. Command gives perfect size of matrix

arrayMATLABmatrixmatrix arraymatrix manipulation

Ts
Ts(:,:,1) =
0.5000 0.5000 1.0000
0.5000 0.5000 -1.0000
-0.5000 0.5000 0
Ts(:,:,2) =
0.5000 0.5000 1.0000
0.5000 0.5000 -1.0000
-0.5000 0.5000 0
Ts(:,:,3) =
1 0 0
0 1 0
0 0 1
Ts(:,:,4) =
1 0 0
0 1 0
0 0 1
Ts(:,:,5) =
1 0 0
0 1 0
0 0 1
L
L(:,:,1) =
1.0e-04 *
0.1215
0.1215
-0.2570
L(:,:,2) =
1.0e-04 *
0.1215
0.1215
-0.2570
L(:,:,3) =
1.0e-04 *
-0.0070
0.2500
0
L(:,:,4) =
1.0e-04 *
-0.0070
0.2500
0
L(:,:,5) =
1.0e-04 *
-0.0070
0.2500
0
STs
STs(:,:,1) =
1.0e-07 *
-0.3210 -0.3210 0.6015
STs(:,:,2) =
1.0e-07 *
-0.3210 -0.3210 0.6015
STs(:,:,3) =
1.0e-07 *
-0.0203 -0.6218 0
STs(:,:,4) =
1.0e-07 *
-0.0203 -0.6218 0
STs(:,:,5) =
1.0e-07 *
-0.0203 -0.6218 0
>> If i using bsxfun(@times, Ts,L); it gives wrong size of matrix. i need command for [3*3]*[3*1] gives [3*1] matrix. [1*3]*[3*1] gives [1] value. please tell command for array multiplication for every size.[3*1]*[1*3] give[3*3].

Best Answer

temp = arrayfun(@(J) Ts(:,:,J)*L(:,:,J), 1:size(Ts,3), 'Uniform', 0);
STs = cell2mat(reshape(temp,1,1,[]));