필터 지우기
필터 지우기

cell array multiplication vectorization

조회 수: 2 (최근 30일)
K.E.
K.E. 2016년 11월 15일
답변: the cyclist 2016년 11월 15일
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)?

답변 (1개)

the cyclist
the cyclist 2016년 11월 15일
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);

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by