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 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
更多回答(1 个)
dpb
2018-10-30
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
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Shifting and Sorting Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!