File Exchange

image thumbnail

FREQTABLE

version 1.0.0.0 (471 Bytes) by Mukhtar Ullah
Frequency table.

0 Downloads

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 (2020). FREQTABLE (https://www.mathworks.com/matlabcentral/fileexchange/6631-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
xb=x([find(d);length(x)]);
x=histc(x,xb);
table=[xb x];
just a thought, us

Updates

1.0.0.0

Fixed a serious bug! Now ignores NANs.

Extended to support character arrays and cell arrays of strings. The interpretation of outputs has been changed to make sense.

a typo corrected.

rewritten as suggested by urs schwarz.

removed one if else statement.

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

Inspired: Rankings