Replace NaN with specific value.
34 ビュー (過去 30 日間)
古いコメントを表示
I have many large column matrices (each is ~20k x 1). Some elements of the matrices are NaN. I want to replace them with 0 (or some number). Is there a quick way for that. Looping through each element is a very inefficient process and delays my program. The help is really appreciated.
0 件のコメント
採用された回答
Guillaume
2016 年 6 月 27 日
編集済み: Guillaume
2016 年 6 月 27 日
yourmatrix(isnan(yourmatrix)) = somevalue;
But, using NaN to mark exceptional values is much better than using 0 or some other special value.
2 件のコメント
Steven Lord
2016 年 6 月 27 日
For a couple releases now the sum function has accepted a flag that lets you specify whether NaN values should be included in the sum (which makes the sum NaN) or excluded (unless all the values being summed are NaN.)
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Data Type Conversion についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!