convert nans to 0

1 次查看(过去 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 CenterFile Exchange 中查找有关 Data Type Conversion 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by