File Exchange

image thumbnail


version (471 Bytes) by Mukhtar Ullah
Frequency table.

1 Download

Updated 07 Jun 2005

No License

FREQTABLE Frequency table.
[Y,N] = FREQTABLE(X) takes a vector X and returns the unique values of
X in theoutput Y, and the number of instances of each value in the
output N. X can be a charachter array or cell array of strings.

Cite As

Mukhtar Ullah (2021). FREQTABLE (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (8)

meinhard ploner

ok, i had a transposed vector in the last try(see last review). surely [1; 1+find(diff(S))] instead of [find(diff(S)); end] does not change anything in terms of performance ;-))

meinhard ploner GMX

i changed the code line after "S=..." to:

B = S([ 1 1+find(diff(S)) ]);

and now it works for me, too. Without the change i got the message: ??? Error using ==> vertcat
CAT arguments dimensions are not consistent.

Celia Sobrino

very smart

Mukhtar Ullah

This function now supports character arrays and cell arrays of strings.

Mukhtar Ullah

Bruno Desart,
In fact, you have pointed out a limitation:
this file can't be used for cell arrays; for cells use tabulate(statistic toolbox)

Bruno Desart

Just one question: how to use this with cell array?
Many thanks in advance.

Mukhtar Ullah

Thanks us! I have rewritten the file according to your suggestions. Your idea is really clever.

urs (us) schwarz

no need to use unique. for large Xs this else-code becomes faster for obvious reasons. note histc is a mexed function.

x=sort(xx(:)); % same conditioning
d=diff(x); % same conditioning
% else code
table=[xb x];
just a thought, us

MATLAB Release Compatibility
Created with R14
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!