FUNCTION REFERENCE

setdiff

Values in A that are not in B.

Values in A that are not in B.

Syntax

C = setdiff(A, B)

Syntax

[C, ia] = setdiff(A, B, 'stable')

Syntax

[C, ia] = setdiff(A, B, 'rows')

Result is sorted by default; 'stable' keeps the order of A. ia holds first indices in A.

Example

setdiff([1 2 3 4], [2 4])   % [1 3]

Differences from MATLAB: Numeric/logical inputs support 2-D arrays with 'rows', 'sorted', or 'stable' (not 'legacy'). Character/cellstr forms also support 'legacy'; 'rows' warns and is ignored for cell inputs.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.