From: Thijs on
Hello,

I have a rowvector with a length of app. 300 that is filled with integer values ranging from 1 to app. 13000. Therefore, most values (out of the range of 1 to 13000) will not be present in the vector, some values will be unique, but other values are present multiple times. I am not really interested in the values that occur only once in the vector, but I do want to know which values occur more than once and also how many times these values occur.

In short, I have two questions:

- How can I check which values occur more than once in my vector?
- How can I see how many occurences (of the values out of my first question) there are?

Thanks in advance for the help.
From: Thijs on
Ok, I have solved one of my two questions myself by:

x = length(v1)-length(unique(v1))

Now only one question remains, how can I find out which numbers were not unique in the rowvector v1?

Thanks.

Thijs

"Thijs " <t.denhamer(a)student.tudelft.nl> wrote in message <i1mtfl$73i$1(a)fred.mathworks.com>...
> Hello,
>
> I have a rowvector with a length of app. 300 that is filled with integer values ranging from 1 to app. 13000. Therefore, most values (out of the range of 1 to 13000) will not be present in the vector, some values will be unique, but other values are present multiple times. I am not really interested in the values that occur only once in the vector, but I do want to know which values occur more than once and also how many times these values occur.
>
> In short, I have two questions:
>
> - How can I check which values occur more than once in my vector?
> - How can I see how many occurences (of the values out of my first question) there are?
>
> Thanks in advance for the help.
From: Sean on
"Thijs " <t.denhamer(a)student.tudelft.nl> wrote in message <i1n0bi$9cn$1(a)fred.mathworks.com>...
> Ok, I have solved one of my two questions myself by:
>
> x = length(v1)-length(unique(v1))
>
> Now only one question remains, how can I find out which numbers were not unique in the rowvector v1?
>
> Thanks.
>

Take a peak at the 2nd/3rd outputs from unique(). Function accumarray() will also help.
From: Sean on
"Thijs " <t.denhamer(a)student.tudelft.nl> wrote in message <i1n0bi$9cn$1(a)fred.mathworks.com>...
> Ok, I have solved one of my two questions myself by:
>
> x = length(v1)-length(unique(v1))
>
> Now only one question remains, how can I find out which numbers were not unique in the rowvector v1?
>

You could do this all in one step with histc().
From: Matt J on
"Thijs " <t.denhamer(a)student.tudelft.nl> wrote in message <i1mtfl$73i$1(a)fred.mathworks.com>...

> In short, I have two questions:
>
> - How can I check which values occur more than once in my vector?
> - How can I see how many occurences (of the values out of my first question) there are?
=============

Values=1:13000;
N=histc(YourVector,Values);

ValuesOccuringMoreThanOnce=Values(N>1);
NumberOfOccurences=N(N>1);
 |  Next  |  Last
Pages: 1 2
Prev: unexplained calllib failure
Next: Topography plot