Multiply cell doubles with a matrix

2 次查看(过去 30 天)
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 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by