[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
uniq -c
From: |
John W. Eaton |
Subject: |
uniq -c |
Date: |
Fri, 27 Aug 2004 13:13:41 -0400 |
On 27-Aug-2004, Mike Miller <address@hidden> wrote:
| Is there a way to count repetitions of a value in a vector? In unix/linux
| we could use "uniq -c" to count consecutive identical lines. Is there
| something analogous in Octave? If not, can one of you come up with a
| clever scheme for doing this within Octave? (I've been on this list long
| enough to know that the answer is yes to that last question!)
|
| I really just need the counts and not a list of the values being counted.
| Hmm... I just realized that if I had an ordinary 'uniq' function, I could
| get the "uniq -c" this way (for column vector x):
|
| [NN,XX] = hist(x,uniq(x))
|
| Then [NN,XX] would be the "uniq -c" output and XX would actually equal
| uniq(x).
Octave has
create_set
intersection
union
Matlab appears to have
unique
union
intersect
setdiff
setxor
ismember
These names are also available in Octave-forge. It looks like the
functions in Octave-forge would not need much work to be included in
the core Octave distribution. I'm not sure what the differences are
between these:
octave octave-forge
create_set unique
intersection intersect
union union
but if possible, they should be merged so we only have one set of set
functions instead of two (the old Octave names could simply become
wrappers around the new compatible functions).
jwe
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------
- uniq -c, Mike Miller, 2004/08/27
- uniq -c,
John W. Eaton <=