convert nans to 0

Hi I have a large matrix and want to convert all nans to zeros. Any help?

 Respuesta aceptada

Oleg Komarov
Oleg Komarov el 28 de Mayo de 2012

0 votos

% 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;

Más respuestas (0)

Categorías

Más información sobre Data Type Conversion en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 28 de Mayo de 2012

Community Treasure Hunt

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

Start Hunting!

Translated by