nan in if statement

조회 수: 94 (최근 30일)
Lama Hamadeh
Lama Hamadeh 2021년 3월 31일
Hi all,
How can I say:
if (a==0 or a==NaN)
%whatever
end
Thanks.
  댓글 수: 1
JKD Power and Energy Solutions
JKD Power and Energy Solutions 2021년 3월 31일
Use the below code:
if (a==0 || isnan(a))
%whatever
end

댓글을 달려면 로그인하십시오.

답변 (2개)

David Hill
David Hill 2021년 3월 31일
if ~a||isnan(a)

Hernia Baby
Hernia Baby 2021년 3월 31일
clc, clear
a = NaN;
if a==0 | isnan(a)
%whatever
a
end
a =
NaN

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by