LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Matlab comman, count distinct items in a vector (https://www.linuxquestions.org/questions/programming-9/matlab-comman-count-distinct-items-in-a-vector-465217/)

jdwilder 07-18-2006 10:01 AM

Matlab comman, count distinct items in a vector
 
I have been looking around the matlab help and cannot find it. I want a command that counts the number of distinct entries in a vector so that I can make a histogram (using hist(Y,nbins)) that is broken into the same number of bins as there are distinct entries.

Thanks

jdwilder 07-18-2006 11:38 AM

ah, I found it, I was just searching for the wrong keyword. The command is unique, and takes an vector or matrix as a parameter, and returns the set for that vector/matrix (removes duplicates). So then to count the number of distinct items just get the length of that vector.


All times are GMT -5. The time now is 07:04 AM.