About Site Map Submit Contact Us Log in | Create an account
Create an account Log In
Average Rating
User Rating:
Visitors Rating:
My rating:

Write review
  • Last update: 5 years ago
  • Total downloads: 24
  • Operating system: Linux, Mac OS X, Win All, BSD, Solaris
  • Publisher: Johannes Keyser
See full specifications

scripts default iconcountRepetitions (Scripts) Publisher's description

How many sequences of any repeated element exist in a vector (and how long are they)? Example below

How many sequences of any repeated element exist in a vector (and how long are they)? Example below.

T = COUNTREPETITIONS(A) returns the total number of repetitions of any
element in A. The n-th element in T is the number of n-time-repetitions
of any element in A.

[T,D] = COUNTREPETITIONS(A) also returns a structure, containing a detailed
listing of all repetitions for each element in A.
D.elements just reflects unique(A). Cell array k in D.listing contains only
the repetitions of D.elements(k), using the same format as T.

Input is restricted to be a vector of type logical, numeric or char.
Matrices don't get rejected, but are interpreted as single vector, written
column-wise from left to right (so possibly not what you want).

For A = [0,1,0,0,1,1,1,42,42,42], [T,D] = COUNTREPETITIONS(A) yields:

T = [2 1 2 0 0 0 0 0 0 0], thus reporting 2x single elements, 1x a tuple,
and 2x a triple of repeated elements.

D = elements: [0 1 42]
listing: {3x1 cell} is also easily interpreted:

D.listing contains all element-wise repetitions in the same order
as indicated by D.elements:

ans =
1 1 0 0 0 0 0 0 0 0 ( there's 1x a single 0, and 1x "[0,0]")
ans =
1 0 1 0 0 0 0 0 0 0 ( there's 1x a single 1, and 1x "[1,1,1]")
ans =
0 0 1 0 0 0 0 0 0 0 ( there's 1x "[42,42,42]")

Thus if you are interested in the repetitions of a specific element, you
may easily use logical indexing. For example:
D.listing{D.elements == 42}, just yields [0 0 1 0 0 0 0 0 0 0].

System Requirements:

MATLAB 7.9 (2009b)
Program Release Status: New Release
Program Install Support: Install and Uninstall

countRepetitions (Scripts) Tags:

Click on a tag to find related softwares

Is countRepetitions (Scripts) your software?

Manage your software

Most Popular

scripts default icon ASK, OOK, FSK, BPSK, QPSK, 8PSK modulation 1.1
ASK, OOK, FSK, BPSK, QPSK, 8PSK modulation contain several functions for digital modulation simulation
scripts default icon Simulink Communication Labs 1.1
Simulink Communication Labs allows you to learn communication systems in greater depth.
scripts default icon M-QAM modulation and demodulation 1.1
M-QAM modulation and demodulation is the QAM modulation and demodulation tech.
scripts default icon LZW Compression/Decompression 1.1
LZW Compression/Decompression - Updated LZW compressor and decompressor with reasonable performance
scripts default icon InSPIRE utility to plot a 2D displacement field (Scripts) 1.0
This program plots the deformation field (displace vectors) contained in vector.txt.