Documentation

relationaloperators

Class: handle

Determine equality or sort handle objects

Syntax

tf = eq(H1,H2)
tf = ne(H1,H2)
tf = lt(H1,H2)
tf = le(H1,H2)
tf = gt(H1,H2)
tf = ge(H1,H2)

Description

tf = eq(H1,H2) Equal. (H1 == H2)

tf = ne(H1,H2) Not equal. (H1 ~= H2)

tf = lt(H1,H2) Less than. (H1 < H2)

tf = le(H1,H2) Less than or equal. (H1 <= H2)

tf = gt(H1,H2) Greater than. (H1 > H2)

tf = ge(H1,H2) Greater than or equal. (H1 >= H2)

For each pair of input arrays (H1 and H2), the operation returns a logical array of the same size. Each element in the returned array is an element-wise equality or comparison test result. These methods perform scalar expansion in the same way as the MATLAB® built-in relational operators. See relationaloperators for more information.

The following guidelines apply to handle comparison:

  • Copies of a handle variable always compare as equal.

  • The repeated comparison of any two handles always yields the same result in the same MATLAB session.

  • Different handles are always not equal.

  • The order of handle values is purely arbitrary and has no connection to the state of the handle objects being compared.

  • If the input arrays belong to different classes (including the case where one input array belongs to a non-handle class such as double) then the comparison is always false.

  • If you make a comparison between a handle object and an object of a dominant class, the method of the dominant class is invoked. You should generally test only like objects because a dominant class might not define one of these methods.

  • An error occurs if the input arrays are not the same size and neither is scalar.

Use isequal when you want to determine if different handle objects have the same data in all object properties.

Input Arguments

collapse all

H1 — Left argument to operatorhandle array

Left argument to operator, specified as a handle array.

H2 — Right argument to operatorhandle array

Right argument to operator, specified as a handle array.

Output Arguments

collapse all

tf — Result of comparisonlogical array

Result of comparison, returned as a logical array of the same size as the input arrays, where each element is an element-wise equality or comparison test result

  • 1 — relationship is true

  • 0 — relationship if not true

Attributes

Accesspublic

To learn about attributes of methods, see Method Attributes in the MATLAB Object-Oriented Programming documentation.

See Also

Was this topic helpful?