Mathematics
7-9
Specify 'sorted' if you want the elements in the output array to be in sorted order. For
example:
C = unique([9 2 2],'sorted') returns C = [2 9].
Set Functions Changing Behavior in a Future Release
In a future release, the behavior of unique, union, intersect, setdiff, setxor, and ismember
will change.
• If there are repeated elements in the input arrays, the functions unique, union,
intersect, setdiff, and setxor will return the index to the first occurrence of the
repeated elements (or rows).
• The optional output array, locb, returned by ismember, will contain the lowest
absolute indices in B for elements (or rows) that are also in A.
• All index vectors returned by unique, union, intersect, setdiff, or setxor will
be column vectors.
• unique and union will support objects with methods sort (sortrows for the
'rows' option), and ne. This includes heterogeneous arrays derived from the same
root class.
• intersect, setdiff, setxor, and ismember will support objects with methods
sort (sortrows for the 'rows' option), ne, and eq. This includes heterogeneous
arrays derived from the same root class.
• The input arrays passed to union, intersect, setdiff, setxor, and ismember
must be of the same class with the following exceptions:
• Logical, char, and all numeric classes can combine with double arrays.
• Cell arrays of strings can combine with char arrays.
Note: The set functions already conform to this behavior when you call them with the
new setOrder argument.
Compatibility Considerations
The new behavior change is introduced for adoption in R2012a. If you want to assess
the impact this change might have on your existing code, specify 'R2012a' as the final
Comments to this Manuals