Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
matrix to cell array

Subject: matrix to cell array

From: Suresh

Date: 16 Aug, 2013 17:31:22

Message: 1 of 3

Hi all,
I am having an Input matirx of size [4x50] and I want to convert it into a [1x50]cell array of [4x1] vectors. Kindly if anyone knows please help me.

Subject: matrix to cell array

From: Josh Meyer

Date: 16 Aug, 2013 17:50:01

Message: 2 of 3



"Suresh " <dnbdsuresh@gmail.com> wrote in message
news:kulnl9$7t1$1@newscl01ah.mathworks.com...
> Hi all,
> I am having an Input matirx of size [4x50] and I want to convert it into a
> [1x50]cell array of [4x1] vectors. Kindly if anyone knows please help me.

If A is your matrix of size 4x50 and B is the cell array, then

subs = kron(1:50,[1 1 1 1])';
B = accumarray(subs, A(:), [], @(x) {x})';

 

Subject: matrix to cell array

From: Steven_Lord

Date: 16 Aug, 2013 18:56:53

Message: 3 of 3



"Suresh " <dnbdsuresh@gmail.com> wrote in message
news:kulnl9$7t1$1@newscl01ah.mathworks.com...
> Hi all,
> I am having an Input matirx of size [4x50] and I want to convert it into a
> [1x50]cell array of [4x1] vectors. Kindly if anyone knows please help me.

http://www.mathworks.com/help/matlab/ref/mat2cell.html

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us