Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.


Jinsoo
Posts:
8
Registered:
9/27/12


Swap elements in a matrix
Posted:
Nov 20, 2012 11:39 PM


Hi,
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!



