Cell Array and Matrix

2 views (last 30 days)
RoboKid
RoboKid on 10 Nov 2013
Edited: per isakson on 17 May 2015
How do I multiply/subtract a cell array and a matrix for Ex. I want to multiply D and L , Cell array
D = {[1 2] , [1 1] ; [1 6 ] , [5 2] };
and matrix
L=[1 0 0 0; 0 1 0 0 ]
  1 Comment
Azzi Abdelmalek
Azzi Abdelmalek on 10 Nov 2013
Edited: Azzi Abdelmalek on 10 Nov 2013
What is the expected result? There are several possibilities

Sign in to comment.

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 10 Nov 2013
Edited: Azzi Abdelmalek on 10 Nov 2013
One of the possibilities
D = {[1 2],[1 1] ;[1 6 ],[5 2]}
L=[1 0 0 0; 0 1 0 0 ];
out=cellfun(@(x) x*L,D,'un',0)
%or maybe
cell2mat(D).*L

More Answers (0)

Categories

Find more on Multidimensional Arrays in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!