How to sort several coordinates ?

6 ビュー (過去 30 日間)
Geoff
Geoff 2012 年 9 月 13 日
Hello everyone !
I'd like to know how to sort the axial and radial coordinates of a range of points only by using the function "sort". For instance, if the row vector x=[3 2 1] matches with y=[4 5 6], I'd wish to obtain x=[1 2 3] and y=[6 5 4]. I specify I don't want to use another function than "sort" and I only work with row vectors.
Thanks a lot for your answers !

採用された回答

Andrei Bobrov
Andrei Bobrov 2012 年 9 月 13 日
x=[3 2 1];
y=[4 5 6];
[xout,i1] = sort(x);
yout = y(i1);
or
xy = sortrows([x;y].',1).';
yout = xy(2,:);
  1 件のコメント
Geoff
Geoff 2012 年 9 月 13 日
Thanks !

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeShifting and Sorting Matrices についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by