How can i multiply cell arrays?

220 ビュー (過去 30 日間)
Gn Gnk
Gn Gnk 2019 年 12 月 6 日
コメント済み: Stephen23 2020 年 12 月 7 日
Hello ,
i want to multiply an array H which is 2x2 cell array (each cell contains a 1x500 array) with an array X which is 2x1 array (also each cells contains 1x500 array) .When i try to multiply these arrays like this H.*X i get the following error: Undefinedoperator '.*' for input arguments of type 'cell'. How can i multiply these cell arrays?
Thank you.

採用された回答

Matt J
Matt J 2019 年 12 月 6 日
for i=1:2
for j=1:2
H{i,j}=H{i,j}.*X{i};
end
end
  1 件のコメント
Gn Gnk
Gn Gnk 2019 年 12 月 7 日
That's excactly what i was looking for .Thank you so much!!

サインインしてコメントする。

その他の回答 (1 件)

choonghyun lee
choonghyun lee 2020 年 12 月 7 日
編集済み: Stephen23 2020 年 12 月 7 日
M = cellfun(@(x,y) x.*y, H,X,'UniformOutput',false)
  1 件のコメント
Stephen23
Stephen23 2020 年 12 月 7 日
M = cellfun(@times, H,X, 'UniformOutput',false)

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by