# setdiffFS

setdiffFS finds the positive integers in a which are not present in the positive integers in b

## Syntax

• c=setdiffFS(a,b)example

## Description

 c =setdiffFS(a, b) Example of use of setdiffFS.

## Examples

expand all

### Example of use of setdiffFS.

Define two vectors (containing positive integers) with values in common.

A = [3 6 2 1 5 1 1];
B = [2 4 6];
C=setdiffFS(A,B);
disp(C);
     1
3
5



## Related Examples

expand all

### Time comparison with setdiff.

20000 calls to setdiff and to setdiffFS.

% Analysis of computational time.
n=100;
nsimul=20000;
tSETDIFF=0;
tSETDIFFFS=0;
for j=1:nsimul
a=randi(n,[300,1]);
b=randi(n,[40,1]);
tsetdiff = tic;
c=setdiff(a,b);
tSETDIFF = tSETDIFF + toc(tsetdiff);
tsetdiffFS = tic;
cFS=setdiffFS(a,b);
tSETDIFFFS = tSETDIFFFS + toc(tsetdiffFS);
if ~isequal(c,cFS)
error('FSDA:setdiffFS:WrongOutput','c and cFS are different')
end
end
disp(array2table([tSETDIFF tSETDIFFFS],'VariableNames',{'setdiff time' 'setdiffFS time'}))

## Input Arguments

### a — vector containing positive integer elements. Vector.

A vector of length na containing positive integer numbers.

Data Types: single| double

### b — vector containing positive integer elements. Vector.

A vector of length nb containing positive integer numbers.

Data Types: single| double

## Output Arguments

### c —Positive integer elements thare are on a but not in b. vector

Column vector.

Note that the elements of c contain no repetitions and are sorted.

## References

Riani, M., Perrotta, D. and Cerioli, A. (2015), The Forward Search for Very Large Datasets, "Journal of Statistical Software"