Multiplication in cell arrays

5 ビュー (過去 30 日間)
lucksBi
lucksBi 2017 年 6 月 15 日
コメント済み: lucksBi 2017 年 6 月 15 日
hey i have 2 cell arrays like this:
mul={[1,1,0.6,0.6,0.3];[1,1,0.6,0.6,0.3,0.3]}
A={[5x3 cell];[6x4 cell]}
in which elements of A are as follows:
A{1,1}={1,2,4;2,0,0;0,1,0;5,0,1;1,0,0}
A{2,1}={3,0,0,0;0,0,0,3;3,0,0,0;2,0,0,2;0,0,0,0;2,0,0,0}
i want to multiply each column with all cells of A with respective cells in 'mul'. e.g. 1st cell of mul which is [1,1,0.6,0.6,0.3] with all columns of A{1,1} and then sum that. which will be: 1x1 + 2x1 + 0x0.6 + 5x0.6 + 1x0.3.. similarly with other two columns.
And then 2nd cell of mul with columns of A{2,1}.
Please help

採用された回答

Andrei Bobrov
Andrei Bobrov 2017 年 6 月 15 日
mul={[1,1,0.6,0.6,0.3];[1,1,0.6,0.6,0.3,0.3]};
A{1,1}={1,2,4;2,0,0;0,1,0;5,0,1;1,0,0};
A{2,1}={3,0,0,0;0,0,0,3;3,0,0,0;2,0,0,2;0,0,0,0;2,0,0,0};
a = cellfun(@(x)cell2mat(x),A,'un',0);
out = cellfun(@(x,y)y*x,a,mul,'un',0);
  1 件のコメント
lucksBi
lucksBi 2017 年 6 月 15 日
Thank You so much for helping :)

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by