Sort Matrix by Columns (descending by the number NaN entries)
7 views (last 30 days)
Show older comments
Once again I need your help!
I have a matrix with a variable number of columns. All these columns have a different number of NaN entries.
I would like to sort the matrix in a way that I have a new matrix with the first column having the lowest number of NaN entries,...
Thanks a lot in advance!
0 Comments
Accepted Answer
Azzi Abdelmalek
on 16 Oct 2012
Edited: Azzi Abdelmalek
on 16 Oct 2012
A=rand(10);ii=randperm(100);A(ii(1:40))=nan %example
[c,idx]=sort(sum(isnan(A)))
out=A(:,idx)
More Answers (0)
See Also
Categories
Find more on Shifting and Sorting Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!