Multiply cell doubles with a matrix

조회 수: 1 (최근 30일)
Mori
Mori 2016년 7월 13일
댓글: Mori 2016년 7월 13일
I have a cell array A which has 1*5 cell, each cell has 12*1 doubles.
How multiply those 12*1 doubles with a MATRIX call B with 12*500 ?
Thank you

채택된 답변

Andrei Bobrov
Andrei Bobrov 2016년 7월 13일
편집: Andrei Bobrov 2016년 7월 13일
out = bsxfun(@times,permute(cell2mat(A),[1,3,2]),B); % out - 3D double array
or
out = cellfun(@(x)bsxfun(@times,x,B),A,'un',0); % here out - cell array (1 x 5)
  댓글 수: 7
Andrei Bobrov
Andrei Bobrov 2016년 7월 13일
for your data (MatFiles.mat):
A1 = cellfun(@(x)[x{:}]',A,'un',0);
out = bsxfun(@times,permute(cell2mat(A1),[1,3,2]),B); % out - 3D double array
or
out = cellfun(@(x)bsxfun(@times,x,B),A1,'un',0); % here out - cell array (1 x 5)
Mori
Mori 2016년 7월 13일
ok great, it works. I relay appreciate.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Cell Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by