Mathematical computation for ordering matrices
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
arun Dhillon
am 11 Mär. 2019
Kommentiert: arun Dhillon
am 11 Mär. 2019
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.
0 Kommentare
Akzeptierte Antwort
Jos (10584)
am 11 Mär. 2019
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
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Encryption / Cryptography finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!