convert nans to 0

1 visualizzazione (ultimi 30 giorni)
Mate 2u
Mate 2u il 28 Mag 2012
Hi I have a large matrix and want to convert all nans to zeros. Any help?

Risposta accettata

Oleg Komarov
Oleg Komarov il 28 Mag 2012
% 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;

Più risposte (0)

Categorie

Scopri di più su Data Type Conversion in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by