How I multiply matrices in a cell?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I have 5 x 19 cell. Each cell has 2 x 2 matrix. I need a 1 x 19 cell which has matrix product of each matrice from individual column.
For a 1 x 5 cell (M_transfer) having 2 x 2 matrix I am able to get matrix product (M1 x M2 x .... x M5) by following code:
M = 1 ; %dummy variable
for i = 1 : 5
M = M * M_transfer{1,i} ;
end
How I do this for 5 x 19 cell? (In final answer I need 19 matrix products stored in a 1 x 19 cell )
0 comentarios
Respuestas (1)
KSSV
el 1 de Jun. de 2022
% Make dummy data for demo
C = cell(5,19) ;
for i = 1:5
for j = 1:19
C{i,j} = rand(2) ;
end
end
M = @(x) prod(x(:)) ; % function to multiple all elements of each 2x2 matrix in each cell array
A = cellfun(M,C) ;
B = prod(A) % multiply 5 column elements of A
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
