Convert zeros to NAN
1 回表示 (過去 30 日間)
古いコメントを表示
I have a matrix (N rows and M columns). It consists of integer values. I want to convert all the zero values from rows 1:N and columns 3:M to NaN. Is there any way to do so.
Thanks, Nancy
0 件のコメント
採用された回答
Sean de Wolski
2011 年 6 月 14 日
One of many ways
idx = ~A;
idx(:,1:2) = false;
A(idx) = nan;
3 件のコメント
Sean de Wolski
2011 年 6 月 14 日
Yes. It sets any value that was a zero value (the ~ (not) command) in the first definition to be false so that it doesn't show up in the nan assignment.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Numeric Types についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!