help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

uniq -c


From: Mike Miller
Subject: uniq -c
Date: Fri, 27 Aug 2004 11:08:30 -0500 (CDT)

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).

Mike



-------------------------------------------------------------
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
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]