I have a 2D matrix (81,000,000 x 2). Each row has a radius value and an intensity value. The radii are not in a monotonic in this 2D matrix. I want to sort 1st column from min to max and have column 2 move with it.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Paul Manhart
am 30 Okt. 2018
Kommentiert: dpb
am 31 Okt. 2018
I have a 9000 x 9000 matrix containing a radial distribution of energy from the center out. I want to plot Value vs. Radius. to fine R= 0 I look for the X,Y position of the maximum pixel,(X0,Y0). Then I go through the matrix and calculate the radius value for each pixel with R = sqrt((X-X0)^2 + (Y - Y0)^2). I store the Radius value and the intensity of that pixel in a two column matrix with Radius in Column 1, value in column 2. How do I sort radius values from min to max and have the associated column #2 go along with the sort? My (npts,2) matrix is about (81,000,000 x 2). I need to sort column 1 in ascending order but can't figure out how to make sure the value in column 2 move along with the sort so it is still associated with that radius value. Can you help?
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (1)
dpb
am 30 Okt. 2018
doc sortrows
Or, of course, you can do it yourself via
[~,ix]=sort(A(:,1)); % return index to sorted position of first column
A=A(ix,:); % reorder A by row in sorted order given by ix
Siehe auch
Kategorien
Mehr zu Matrices and Arrays 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!