sorting coordiantes from a file

i have a file which i load in matlab
the file has three columns
*xvalues* *y values* *energy values*
4 5 344
5 1 285
0 0 455
0 1 203
the problem is i want to arrange 1st and 2nd columns as coordinates , so that (0,0) is followed by (0,1) and so on with there values ..
how can i sort it to align values such that the above chart is sorted to
0 0 455
0 1 203
4 5 344
5 1 285

답변 (3개)

Walter Roberson
Walter Roberson 2012년 12월 12일

1 개 추천

sortrows()
saad
saad 2012년 12월 12일
편집: saad 2012년 12월 12일

0 개 추천

Walter ,
I have used sortrow , but the example above was a toy ..
if
a=
4 5 344
5 1 285
0 1 455
0 0 203
and i do b=sortrows(a,1)
then
still the second column is not arranged
0 1 455
0 0 203
4 5 344
5 1 285
where as i want to arrange exact coordinates like
b=
0 0 455
0 1 203
4 5 344
5 1 285

댓글 수: 1

sortrows(a)
Note: in your sample "a" here, your 4th row is [0 0 203] which does not appear in your desired output "b". Your desired output corresponds to your original data matrix.
saad
saad 2012년 12월 12일

0 개 추천

oh sorry that was a typo
now
a=
a=
4 5 344
5 1 285
0 1 455
0 0 203
b=sortrows(a,1) give
b=
0 1 455
0 0 203
4 5 344
5 1 285
Where as what i want is
b=
0 0 203
0 1 455
4 5 344
5 1 285

댓글 수: 3

b = sortrows(a)
Notice that I did not have a ,1 argument.
saad
saad 2012년 12월 12일
Thanks , solved -----
Image Analyst
Image Analyst 2012년 12월 13일
Then mark this question as "Answered" - OK?

이 질문은 마감되었습니다.

태그

질문:

2012년 12월 12일

마감:

2021년 8월 20일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by