File Exchange

image thumbnail


version 1.0 (585 Bytes) by

Frequency table.



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.

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


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
MATLAB 7 (R14)

Inspired: Rankings

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video