| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
c = setdiff(A, B)
c = setdiff(A, B, 'rows')
[c,i] = setdiff(...)
c = setdiff(A, B) returns the values in A that are not in B. In set theory terms, c = A - B. Inputs A and B can be numeric or character vectors or cell arrays of strings. The resulting vector is sorted in ascending order.
c = setdiff(A, B, 'rows'), when A and B are matrices with the same number of columns, returns the rows from A that are not in B.
[c,i] = setdiff(...) also returns an index vector index such that c = a(i) or c = a(i,:).
Because NaN is considered to be not equal to itself, it is always in the result c if it is in A.
A = magic(5); B = magic(4); [c, i] = setdiff(A(:), B(:)); c' = 17 18 19 20 21 22 23 24 25 i' = 1 10 14 18 19 23 2 6 15
intersect, ismember, issorted, setxor, union, unique
![]() | setDefaultStream (RandStream) | setDirectory (Tiff) | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |