| Contents | Index |
Set intersection for categorical arrays
Note In a future release, the behavior of categorical.intersect will change to be consistent with the MATLAB function intersect. This behavior change is optional in R2012a. For a demonstration of using the 'R2012a' flag to preview the future behavior, or the 'legacy' flag to preserve the current behavior in your existing code, see the documentation for intersect. |
C = intersect(A,B)
[C,IA,IB] = intersect(A,B)
[...] = intersect(A,B,'rows')
[...] = intersect(...,'R2012a')
[...] = intersect(...,'legacy')
[...] = intersect(A,B,setOrder)
[...]
= intersect(A,B,'rows',setOrder)
C = intersect(A,B) for categorical vectors A and B, returns a categorical vector C containing the values common to the two vectors with no repetitions. The result C is sorted. The set of categorical levels for C is the sorted union of the sets of levels of the inputs.
[C,IA,IB] = intersect(A,B) also returns index vectors IA and IB such that C = A(IA) and C = B(IB). If there are repeated common values in A or B, then the index of the last occurrence of each repeated value is returned.
[...] = intersect(A,B,'rows') for categorical matrices A and B with the same number of columns, returns the rows common to the two matrices. The rows of the matrix C are sorted. The set of categorical levels for C is the sorted union of the sets of levels of the inputs. The optional outputs IA and IB are index vectors such that C = A(IA,:) and C = B(IB,:).
[...] = intersect(...,'R2012a') adopts the future behavior of intersect. You can specify the flag as the final argument with any previous syntax that accepts A, B, or 'rows'.
[...] = intersect(...,'legacy') preserves the current behavior of intersect. You can specify the flag as the final argument with any previous syntax that accepts A, B, or 'rows'.
[...] = intersect(A,B,setOrder) and [...] = intersect(A,B,'rows',setOrder) returns the observations of C in a specific order. setOrder='sorted' returns the values or rows of C in sorted order. setOrder='stable' returns the values or rows of C in the same order as A. If A and B are row vectors, then C is also a row vector. Otherwise, C is a column vector. IA and IB are column vectors. If there are repeated common values in A or B, then the index of the first occurrence of each repeated value is returned.
ismember | setdiff | setxor | union | unique
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |