"not equal to" in MATLAB
조회 수: 3,030 (최근 30일)
이전 댓글 표시
How do I use "not equal to" symbol in MATLAB?
The above code gives an error.
답변 (5개)
Jan
2019년 6월 14일
Several possible ways:
if 1 ~= 2
if not(1 == 2)
if ~(1==2)
if ne(1, 2)
if ~eq(1, 2)
if 1 - 2 % Implicitly evaluated: all(1 - 2)
댓글 수: 0
Richard Payne
2021년 2월 20일
Is there hack to accept != ?
댓글 수: 1
Steven Lord
2021년 2월 21일
No. The ! operator means whatever follows will be passed to the operating system (assuming it is the first part of the command, otherwise it is an error.) You cannot change that definition. The ~ operator means logical negation, and the ~= operator means not equals.
a = ~true
b = 1 ~= 2
!date
Prannoy
2023년 6월 4일
In MATLAB, the ! operator has a separate meaning. '~' is used instead as a logical NOT operator. This means that "not equal to" will be represented by "~=" in MATLAB. I hope that clears your doubt.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Operators and Elementary Operations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!