How to rearrange the rows of a matrix so the column values loop
Show older comments
I have a matrix
rec =
[ 0 0
0 0.4
0.2 0
1.0 0.4
1.0 0.9 ]
I want it rearranged so that it appears like so
rec_new =
[ 0.2 0
0 0
0 0.4
1.0 0.9
1.0 0.4 ]
If you take any one of these columns and concatenate it onto itself, the values loop from a minimum to a maximum. How can I get a program to automatically do this for a number of matrices? I'm not sure how to start this, so any help would be appreciated.
Ultimately, I need the pairs of points rearranged so that when they are graphed they form a polygon that does not intersect itself.
Thanks
Accepted Answer
More Answers (1)
Leah
on 19 Jun 2013
0 votes
"If you only want them to be counter-clock wise, why not convert the [x,y] point to polar coordinate and sort them by angle?"
Categories
Find more on Numerical Integration and Differentiation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!