Borrar filtros
Borrar filtros

Quick NAN Question HELP!

1 visualización (últimos 30 días)
Xiao Tang
Xiao Tang el 2 de Jul. de 2012
A = [1 2 3 1 nan];
If I input
AA~=1
It returns
ans =
0 1 1 0 1
However, If I want to find the replace the un-null elements with 1, returning a matrix like,
ans =
1 1 1 1 0
I tried A~= nan,
However, it returns
ans =
1 1 1 1 1
Any suggestions?

Respuesta aceptada

Thomas
Thomas el 2 de Jul. de 2012
use isnan
A = [1 2 3 1 nan];
~(isnan(A))
ans =
1 1 1 1 0

Más respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by