Mathematical computation for ordering matrices

1 次查看(过去 30 天)
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Encryption / Cryptography 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by