setdiff
Returns a matrix of the elements in matrix that are not in another specified matrix.
Syntax
setdiff(a,b)
setdiff(a,b,'rows')
[c,ia] = setdiff(...)
Inputs
- a,b
- The set of elements to find the differences between.
- 'rows'
- Find the set difference along the rows as opposed to the elements.
Outputs
- c
- Differences between a and b in ascending order.
- ia
- Index vector derived from c = a(ia).
Examples
setdiff([1,5,2;6,2,6],[9;0;1;2])
ans = [Matrix] 2 x 1
5
6
[x,y]=setdiff([1,5,2;6,2,6],[9;0;1;2])
x = [Matrix] 2 x 1
5
6
y = [Matrix] 2 x 1
3
6
setdiff([1,5,2;6,2,6],[1 2 6],'rows')
ans = [Matrix] 2 x 3
1 5 2
6 2 6