Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Delete and insert row in different matrix
Replies: 5   Last Post: Aug 20, 2013 11:38 PM

 Search Thread: Advanced Search

 Messages: [ Previous | Next ]
 Nasser Abbasi Posts: 6,677 Registered: 2/7/05
Re: Delete and insert row in different matrix
Posted: Aug 20, 2013 3:00 PM
 Plain Text Reply

On 8/20/2013 12:16 PM, John Dickson wrote:
> Hi I am trying to delete ith row from A matrix and insert the same row in B matrix,
>is it possible in matlab?
> I am successful in deleting the ith row using A(i,:)=[]
> Not sure how to insert the same deleted row into another matrix B.
> Any help is appreciated.
>
> Thanks
>

------------------------
clear all
A = rand(5);
B = rand(5);
i = 3; % handling corner cases of 1 and end left as exercise
B = [B(1:i-1,:); A(i,:) ; B(i:end,:)]
A(i,:) = [];
----------------------------

--Nasser

Date Subject Author
8/20/13 John Dickson
8/20/13 Alan
8/20/13 John Dickson
8/20/13 Alan
8/20/13 Nasser Abbasi
8/20/13 John Dickson

© The Math Forum at NCTM 1994-2018. All Rights Reserved.