Mathematical computation for ordering matrices

1 回表示 (過去 30 日間)
arun Dhillon
arun Dhillon 2019 年 3 月 11 日
コメント済み: arun Dhillon 2019 年 3 月 11 日
HEllo Everyone
Please help me with the following problem.
I am having a variable matrix of the size n*2(please see attached image). The first column is all the x values and the second column is all the y values. I want to use all those x,y pairs in a sequence and run an algorithm on each of those x,y pairs. The way i want to use the sequence is that first the smallest y value and its coresponding x value should be chosen to run the algo. upon. Then the next bigger y value should be choosen and the corresponding x value with it must be used to run the algorithm upon. In case of attached image file. The first pair of x,y that should be choosen to run the algo upon should be 261.3794,62.5125; then second value to run the algo upon should be 423.0914,65.1643 and so on. Please edify me that how can i do the same.variable.PNG

採用された回答

Jos (10584)
Jos (10584) 2019 年 3 月 11 日
You can sort the values according to the second column using sortrows. Something along these lines might work for you:
centers = sortrows(centers, 2)
for k=1:size(centers, 1)
XY = centers(k,:) ;
RunMyAlgo (XY)
end
  1 件のコメント
arun Dhillon
arun Dhillon 2019 年 3 月 11 日
Thank you so much Jos. It works great.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDenoising and Compression についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by