The Math Forum

Search All of the Math Forum:

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

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

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

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   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
  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,:) = [];


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

[Privacy Policy] [Terms of Use]

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