"not equal to" in MATLAB
1,831 ビュー (過去 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!
