Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


Math Forum » Discussions » Software » comp.soft-sys.matlab

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

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Nasser Abbasi

Posts: 5,694
Registered: 2/7/05
Re: Delete and insert row in different matrix
Posted: Aug 20, 2013 3:00 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic 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




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.