Multiplication in cell arrays

2 次查看(过去 30 天)
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);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by