MATLAB: How to write a loop for finding similar values in the first column and then sort them in a way corresponding values in a same row sort according to the first column

latitudelongitudesloopsort

I have three columns of data including longitudes, latitudes and gravities respectively. The Matrix has 6882 rows in which after 31 rows longitudes are repeating. I would like to write a loop in a way to find similar longitudes in the first column and then sort longitudes in an ascending order. Since every row (including a longitude, latitude and gravity) belongs to one point, when I find similar longitudes and sort them in the first column I need corresponding data for each point in the second and third columns arrange according to the first column too.

Best Answer

How about using the second output of sort to re-order the rows, or better yet: use sortrows. No need for any loop if you need to sort values.
Related Question