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 conversion

Subject: matrix conversion

From: Aneesh

Date: 28 Sep, 2010 21:48:04

Message: 1 of 4

Can anybody help me in letting me know if there is any command to convert n x n matrix to n^2 x 1.

For Example:

2 x 2 matrix to 4 x 1.

Subject: matrix conversion

From: Jeremy_Greenwald

Date: 28 Sep, 2010 21:52:34

Message: 2 of 4

I believe RESHAPE is what you are looking for if you want to preserve the
number of elements in your array. If you want to change the number of
elements try looking at REPMAT.

"Aneesh " <agoly@fau.edu> wrote in message
news:i7tnqk$5t7$1@fred.mathworks.com...
> Can anybody help me in letting me know if there is any command to convert
> n x n matrix to n^2 x 1.
>
> For Example:
>
> 2 x 2 matrix to 4 x 1.
>

Subject: matrix conversion

From: Sean

Date: 28 Sep, 2010 21:54:04

Message: 3 of 4

"Aneesh " <agoly@fau.edu> wrote in message <i7tnqk$5t7$1@fred.mathworks.com>...
> Can anybody help me in letting me know if there is any command to convert n x n matrix to n^2 x 1.
>
> For Example:
>
> 2 x 2 matrix to 4 x 1.

help reshape

or
x(:)

You may need to transpose() or permute() the array first depending on how you want to reshape it. 'help' works for both of those.

Subject: matrix conversion

From: Matt J

Date: 28 Sep, 2010 21:57:04

Message: 4 of 4

"Aneesh " <agoly@fau.edu> wrote in message <i7tnqk$5t7$1@fred.mathworks.com>...
> Can anybody help me in letting me know if there is any command to convert n x n matrix to n^2 x 1.
=====

If X is your matrix, then X(:) will stack all elements into a single column.

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