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: Swap elements in a matrix
Replies: 2   Last Post: Nov 21, 2012 12:50 AM

Advanced Search

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

Posts: 8
Registered: 9/27/12
Swap elements in a matrix
Posted: Nov 20, 2012 11:39 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply


I have a question about swapping elements in a matrix. I would like to swap elements in the matrix without making a new matrix. Though I googled about any functions, I failed to find out. Below is the example that shows my intent.

a = [ 3 1 2
2 1 1
5 4 4 ]

I want to change a(1,2) -> a(2,1) and a(2,1)->a(1,2). The edited matrix a will be like this.

a= [ 3 2 2
1 1 1
5 4 4]

Your words will be highly appreciated! Enjoy your Thanksgiving!

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.