Home Basics on Matlab function Unique
Reply: 0

Basics on Matlab function Unique

user1931
1#
user1931 Published in June 18, 2018, 3:36 am

I'm studying the function unique, which looks simple at a first sight but I don't understand some properties.

I created a matrix A and tried to analyze the outputs:

A=[5 2 4 5;
   1 1 3 4;
   6 1 2 3]

[C0,IA0,IC0]=unique(A)

[Cr,IAr,ICr]=unique(A,'rows')

[Cf,IAf,ICf]=unique(A,'first')
  1. In C0 the logic of the output is "create a vector in which there are values that appears at least one time"

    But I don't know the meaning of IA0 and IC0. I just know the relation that C=A(IA0) and A=C(IC0). Are these 2 output created only to satisfy this two relation? So why should I be intersted in their outputs?

  2. In Cr ('rows' example) the logic of the output is "give me back the rows of the original matrix A but sorted ascending. Also, if you find at least two or more rows that repeat with same values and order, show that row only once in Cr output"

    The logic of IAr is very intuitive: "give me back the index that must follow the Cr output to order the rows." So in my example gives me back a vector like IAr=[2;1;3]. Thus the second row of the original matrix A must be the first in the Cr output, the first row in A matrix must be the second in Cr...

    But I still don't understand the output ICr

  3. In Cf ('first' example) gives me back the same output as C0. And it's not really clear to me how to use properly this function.


Can anyone gives me a simple explanation about how this function works?

Are there any simple practical examples in which I can take advantage of these other outputs?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.316687 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO