Skip to content


Element-wise comparison of arrays

eq(A, B)

  • A and B should have the same sizes.
  • The output has the same size as A and B.
  • An element of the output is assigned logical 1 if the corresponding elements of A and B are equal, logical 0 if otherwise.
  • If one of the arguments is scalar, this function compares the scalar with each element of the other argument.
  • It gives the same result as A == B.

Example 1: Comparing a scalar to each element of an array.

eq([1 2 3;-2 2 4], 2)
ans =
0   1   0
0   1   0