ne

Not equal to, the function form of the operator ~=.

Category: Symbolic Computations in MATLAB > Operators and Elementary Operations

Syntax

C = ne(A, B)

Same as A ~= B.

Description

The operator A ~= B is true where the elements differ. Unlike the ordered comparisons, complex numbers are compared in both real and imaginary parts, and NaN ~= NaN is true, since NaN is not equal to anything.

For character arrays the comparison is done per character, so the arrays need the same size or one of them must be scalar.

Input arguments

A, B
Numeric, character or string arrays, or symbolic scalars. Sizes must be compatible (equal, or one is scalar, or broadcasting applies).

Output arguments

C
Logical array with the broadcast size. With symbolic operands, a symbolic relation such as x > 1.

Example

Numbers, text and NaN

ne([1 2 3], 2)
ne('abc', 'abd')
ne(NaN, NaN)
Output
ans = 1×3 logical array

   1   0   1
ans = 1×3 logical array

   0   0   1
ans = logical
   1

See also

eq gt lt isequal not