Borrar filtros
Borrar filtros

cell array multiplication vectorization

2 visualizaciones (últimos 30 días)
K.E.
K.E. el 15 de Nov. de 2016
Respondida: the cyclist el 15 de Nov. de 2016
I have J and K a cell array of matrices inside. I want to obtain L
J =
[18x18 double]
[18x18 double]
[18x18 double]
[18x18 double]
[18x18 double]
[18x18 double]
[18x18 double]
[18x18 double]
K =
[18x18 double]
[18x18 double]
[18x18 double]
[18x18 double]
[18x18 double]
[18x18 double]
[18x18 double]
[18x18 double]
M = magic(18);
In for loop:
L = cell(8,1);
for ii = 1:8
L{ii} = M*J{ii}'*K{ii};
end
How can I do this in a vectorized form (cell)?

Respuestas (1)

the cyclist
the cyclist el 15 de Nov. de 2016
This is a bit obfuscated, and I am not sure if it is an faster than a more straightforward version.
% Create some pretend data to mimic yours
M = magic(18);
for ii = 1:8
J{ii} = rand(18);
K{ii} = rand(18);
end
% Vectorized multiplication
C = cellfun(@(a,b,c)(a*b'*c),repmat({M},1,8),J,K,'UniformOutput',false);

Categorías

Más información sobre Matrices and Arrays 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!

Translated by