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:
Matlab newbie: how to turn column into matrix?

Subject: Matlab newbie: how to turn column into matrix?

From: Ann St

Date: 29 Mar, 2010 19:00:22

Message: 1 of 3

Hi everyone:

I have written code in C++ to perform calculations. I now want to plot the results in Matlab. The results are a vector of positions and a matrix of data. I want to plot each column of the matrix against the position vector.

The problem is when I output my results from c++ as ".txt" files, then "load" them into Matlab... The matrix is converted into a long column. I need to know how to convert the long column back into a matrix. I can use the size of the position vector as a control on the number of columns the matrix should have. Does anyone know how to do this (construct a matrix from a column)?

The problem I'm having with outputting my matrix and having it turned into a column is probably related to xCode. I can't figure out the bug; it would be easier just to use Matlab to reconstruct the matrix!

Thanks a lot for any advice.

Subject: Matlab newbie: how to turn column into matrix?

From: Sadik

Date: 29 Mar, 2010 19:11:08

Message: 2 of 3

Hi,

reshape would do it for you.

Best.

Subject: Matlab newbie: how to turn column into matrix?

From: us

Date: 29 Mar, 2010 19:29:06

Message: 3 of 3

"Ann St" <annettestone83@yahoo.com> wrote in message <hoqtc6$pod$1@fred.mathworks.com>...
> Hi everyone:
>
> I have written code in C++ to perform calculations. I now want to plot the results in Matlab. The results are a vector of positions and a matrix of data. I want to plot each column of the matrix against the position vector.
>
> The problem is when I output my results from c++ as ".txt" files, then "load" them into Matlab... The matrix is converted into a long column. I need to know how to convert the long column back into a matrix. I can use the size of the position vector as a control on the number of columns the matrix should have. Does anyone know how to do this (construct a matrix from a column)?
>
> The problem I'm having with outputting my matrix and having it turned into a column is probably related to xCode. I can't figure out the bug; it would be easier just to use Matlab to reconstruct the matrix!
>
> Thanks a lot for any advice.

before CSSM goes on to suggest RESHAPE, can you show a small sequence of your output...

us

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