MATLAB Answers

0

"not equal to" in MATLAB

Asked by Mobile Computing on 14 Jun 2019
Latest activity Commented on by Steven Lord
on 14 Jun 2019
How do I use "not equal to" symbol in MATLAB?
not_equal.png
The above code gives an error.

  2 Comments

When I searched the internet for "MATLAB not equal" this was the first link returned:
which shows all of the element-wise logical operators, with links at the bottom to the relevant pages, e.g.:
Did you try looking at the MATLAB documentation?
FYI for Mobile Computing, the exclamation point (bang) has a different meaning in MATLAB.

Sign in to comment.

2 Answers

Answer by Jan
on 14 Jun 2019

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 Comments

Sign in to comment.


Answer by Manvi Goel on 14 Jun 2019

You can use the ~ instead of ! for not in MATLAB
correct.png

  1 Comment

"You can use..."
It's not you can. It's you have to.

Sign in to comment.