Home Basics on Matlab function Unique
Reply: 0

Basics on Matlab function Unique

user10869
1#
user10869 Published in September 21, 2018, 8:51 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?

share|improve this question

closed as too broad by Sardar Usama, Ander Biguri, Adriaan, Andras Deak, Dev-iL Feb 13 at 13:33

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 3
    Have you read the documentation? – Ander Biguri Feb 13 at 11:52
  • yes i did, but it's explained in general. – Carlo Feb 13 at 12:22
  • 5
    Your question asks for a general explanation. – Will Feb 13 at 12:37
  • 5
    General intuition.com is a bad documentation page, not based in facts. Use the real documentation page – Ander Biguri Feb 13 at 13:24
  • 2
    I came here because I thought it was about the function Uninque, I had never heard of it and thought I could learn something new. – Cris Luengo Feb 13 at 16:52

1 Answer 1

active oldest votes
up vote -4 down vote accepted
You need to login account before you can post.

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

© 2016 Powered by mzan.com design MATCHINFO