Ignore NaN values when sorting
古いコメントを表示
Good afternoon everybody!
I have a matrix of the type:
A = [10 NaN 20 NaN]
and I want to put a rank in ascending order to these values but, if there is a NaN value, it is ignored or set equal to 0.
For instance, the result can be:
rank = [1 0 2 0]
It would be awesome if you can help me with this enigma.
Thank you!
採用された回答
その他の回答 (1 件)
madhan ravi
2020 年 7 月 22 日
[~, where] = sort(A);
Wanted = where .* ~isnan(A)
カテゴリ
ヘルプ センター および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!