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:
Copy Rows from One Matrix to Another

Subject: Copy Rows from One Matrix to Another

From: Amy

Date: 9 Nov, 2010 20:19:04

Message: 1 of 7

I have used xlsread to create two matrices in Matlab. They aren't the same size or shape but two columns in both contain the same sort of data. I'd like to search for data that meets some criteria and then copy those rows from that matrix to another. I'd love any advice.

Subject: Copy Rows from One Matrix to Another

From: Sean

Date: 9 Nov, 2010 21:25:06

Message: 2 of 7

"Amy " <asopinka@uvic.ca> wrote in message <ibcabo$6c8$1@fred.mathworks.com>...
> I have used xlsread to create two matrices in Matlab. They aren't the same size or shape but two columns in both contain the same sort of data. I'd like to search for data that meets some criteria and then copy those rows from that matrix to another. I'd love any advice.

Provide a small set of example data, expected results, and why those results are expected and we'll be able to help you. You've given us no real incite to your problem.

Subject: Copy Rows from One Matrix to Another

From: James Tursa

Date: 9 Nov, 2010 21:26:04

Message: 3 of 7

"Amy " <asopinka@uvic.ca> wrote in message <ibcabo$6c8$1@fred.mathworks.com>...
> I have used xlsread to create two matrices in Matlab. They aren't the same size or shape but two columns in both contain the same sort of data. I'd like to search for data that meets some criteria and then copy those rows from that matrix to another. I'd love any advice.

Please provide a more specific question. What, exactly, do you need help with? What do your matrices look like? Do you need help with how to search, or how to copy rows, or both? etc. etc. Maybe you could provide a short example showing some inputs and desired outputs.

James Tursa

Subject: Copy Rows from One Matrix to Another

From: someone

Date: 9 Nov, 2010 21:32:04

Message: 4 of 7

"Amy " <asopinka@uvic.ca> wrote in message <ibcabo$6c8$1@fred.mathworks.com>...
> I have used xlsread to create two matrices in Matlab. They aren't the same size or shape but two columns in both contain the same sort of data. I'd like to search for data that meets some criteria and then copy those rows from that matrix to another. I'd love any advice.

Could you provide an example?

To paraphrase, what is meant by copy the rows where the columns are similiar?

If the matricies aren't the same size, do they at least have the same number of rows (or columns)?

Subject: Copy Rows from One Matrix to Another

From: Amy

Date: 9 Nov, 2010 21:55:05

Message: 5 of 7

The first matrix has 10 columns and is about 3800 row. One of the columns is the hour and another has a price.
The second matrix has 6 columns and 81 rows and also has a column for the hour and another for the price.

I want to sort the second matrix by hour and copy the rows (or possibly just some cells) to the first matrix so that all the data is in one place i.e. all the hour 1 data is in matrix one, then do the same for hours 2 to 24.



"someone" <someone@somewhere.net> wrote in message <ibcekk$jf0$1@fred.mathworks.com>...
> "Amy " <asopinka@uvic.ca> wrote in message <ibcabo$6c8$1@fred.mathworks.com>...
> > I have used xlsread to create two matrices in Matlab. They aren't the same size or shape but two columns in both contain the same sort of data. I'd like to search for data that meets some criteria and then copy those rows from that matrix to another. I'd love any advice.
>
> Could you provide an example?
>
> To paraphrase, what is meant by copy the rows where the columns are similiar?
>
> If the matricies aren't the same size, do they at least have the same number of rows (or columns)?

Subject: Copy Rows from One Matrix to Another

From: Sean

Date: 9 Nov, 2010 22:12:03

Message: 6 of 7

"Amy " <asopinka@uvic.ca> wrote in message <ibcfvp$h35$1@fred.mathworks.com>...
> The first matrix has 10 columns and is about 3800 row. One of the columns is the hour and another has a price.
> The second matrix has 6 columns and 81 rows and also has a column for the hour and another for the price.
>
> I want to sort the second matrix by hour and copy the rows (or possibly just some cells) to the first matrix so that all the data is in one place i.e. all the hour 1 data is in matrix one, then do the same for hours 2 to 24.
>

doc sortrows
doc vertcat

Subject: Copy Rows from One Matrix to Another

From: Tobi Rasheed

Date: 9 Nov, 2010 22:48:03

Message: 7 of 7

"Sean " <sean.dewolski@nospamplease.umit.maine.edu> wrote in message <ibcgvj$lbj$1@fred.mathworks.com>...
> "Amy " <asopinka@uvic.ca> wrote in message <ibcfvp$h35$1@fred.mathworks.com>...
> > The first matrix has 10 columns and is about 3800 row. One of the columns is the hour and another has a price.
> > The second matrix has 6 columns and 81 rows and also has a column for the hour and another for the price.
> >
> > I want to sort the second matrix by hour and copy the rows (or possibly just some cells) to the first matrix so that all the data is in one place i.e. all the hour 1 data is in matrix one, then do the same for hours 2 to 24.
> >
>
> doc sortrows
> doc vertcat

hi Amy, try sorting the valu using MS EXCEL and get the matrices back in matlab window using the excelink function.

Tags for this Thread

No tags are associated with 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