Multiplication in cell arrays

조회 수: 1 (최근 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 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