convert nans to 0

7 ビュー (過去 30 日間)
Mate 2u
Mate 2u 2012 年 5 月 28 日
Hi I have a large matrix and want to convert all nans to zeros. Any help?

採用された回答

Oleg Komarov
Oleg Komarov 2012 年 5 月 28 日
% Sample input with some NaNs
A = rand(10);
A(randi([1 100],[20,1])) = NaN;
% Detect and replace NaNs
idx = isnan(A);
A(idx) = 0;

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by