Matlab: Matrix multiplication of many matrices in cell arrays -
i have cell array size 1x200x201, in each cell 2x2 matrix. need multiply matrices in way resulting matrix: 2x2x201. means: cell_m{1,1,1}* cell_m{1,2,1}*cell_m{1,3,1}*... , on 200, , same 201 ( cell_m{1,1,2}* cell_m{1,2,2}*cell_m{1,3,2}*... ). cell arrays way handling data. effective way multiplications?
floating-point matrix multiplication not associative in general, a*b*c*d ambiguous. in code assume looking ((a*b)*c)*d
d=size(cell_m); p = cell(d(1), 1, d(3)); p(:)={eye(2)}; k=1:d(2), p = cellfun(@mtimes, p(:,1,:), cell_m(:,k,:), 'uniformoutput', false); end p = squeeze(p); now p cell array of 201 elements each element 2-by-2 matrix.
Comments
Post a Comment