Multiplication in cell arrays

2 visualizaciones (últimos 30 días)
lucksBi
lucksBi el 15 de Jun. de 2017
Comentada: lucksBi el 15 de Jun. de 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

Respuesta aceptada

Andrei Bobrov
Andrei Bobrov el 15 de Jun. de 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);
  1 comentario
lucksBi
lucksBi el 15 de Jun. de 2017
Thank You so much for helping :)

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Resizing and Reshaping Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by