The unique function and ismember function of MATLAB Foundation

Source: Internet
Author: User

(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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.