フィルターのクリア

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 Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by