nan in if statement

Hi all,
How can I say:
if (a==0 or a==NaN)
%whatever
end
Thanks.

1 comentario

JKD Power and Energy Solutions
JKD Power and Energy Solutions el 31 de Mzo. de 2021
Use the below code:
if (a==0 || isnan(a))
%whatever
end

Iniciar sesión para comentar.

Respuestas (2)

Hernia Baby
Hernia Baby el 31 de Mzo. de 2021

1 voto

clc, clear
a = NaN;
if a==0 | isnan(a)
%whatever
a
end
a =
NaN

Categorías

Más información sobre MATLAB en Centro de ayuda y File Exchange.

Preguntada:

el 31 de Mzo. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by