Effacer les filtres
Effacer les filtres

Mathematical computation for ordering matrices

2 vues (au cours des 30 derniers jours)
arun Dhillon
arun Dhillon le 11 Mar 2019
Commenté : arun Dhillon le 11 Mar 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.variable.PNG

Réponse acceptée

Jos (10584)
Jos (10584) le 11 Mar 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
  1 commentaire
arun Dhillon
arun Dhillon le 11 Mar 2019
Thank you so much Jos. It works great.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Denoising and Compression dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by