nan in if statement

116 Ansichten (letzte 30 Tage)
Lama Hamadeh
Lama Hamadeh am 31 Mär. 2021
Hi all,
How can I say:
if (a==0 or a==NaN)
%whatever
end
Thanks.
  1 Kommentar
JKD Power and Energy Solutions
Use the below code:
if (a==0 || isnan(a))
%whatever
end

Melden Sie sich an, um zu kommentieren.

Antworten (2)

David Hill
David Hill am 31 Mär. 2021
if ~a||isnan(a)

Hernia Baby
Hernia Baby am 31 Mär. 2021
clc, clear
a = NaN;
if a==0 | isnan(a)
%whatever
a
end
a =
NaN

Community Treasure Hunt

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

Start Hunting!

Translated by