(1) Unique function
function format:
b = Unique (a)% takes a vector of the non-repeating elements of set A;
B = Unique (A, ' rows ')% returns a, B matrix consisting of different line elements;
[B,i,j] = unique (...) % where I reflects the position of elements in B in the original vector (matrix A), J reflects the position of the original vector (matrix a) in B;
Code:
>> a=[1 2 3;4 5 6;7 8 9;1 2 3;5 5 5;6 6 6;6 7 8]a = 1 2 3 4 5 6 7 8 9 1
2 3 5 5 5 6 6 6 6 7 8>> a1=unique (A, ' rows ') A1 = 1 2 3 4 5 6 5 5 5 6 6 6 6 7 8 7 8
(2) IsMember
tf = IsMember (a,s)
tf = IsMember (a,s, ' rows ')
[TF, loc] = IsMember (a,s,...)
The A1 in the code is still the above A1 (the example here is about matrices)
The code is as follows:
>> a=[1 2 3]a = 1 2 3>> [Tfa,loca] = IsMember (a,a1, ' rows ') TFA = 1loca =
The unique function and ismember function of MATLAB Foundation