Multiplication in cell arrays

2 visualizzazioni (ultimi 30 giorni)
lucksBi
lucksBi il 15 Giu 2017
Commentato: lucksBi il 15 Giu 2017
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

Risposta accettata

Andrei Bobrov
Andrei Bobrov il 15 Giu 2017
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);

Più risposte (0)

Categorie

Scopri di più su Resizing and Reshaping Matrices in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by