No BSD License  

5.0

5.0 | 4 ratings Rate this file 6 Downloads (last 30 days) File Size: 585 Bytes File ID: #6631

FREQTABLE

by

 

27 Dec 2004 (Updated )

Frequency table.

| Watch this File

File Information
Description

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.

Acknowledgements

This file inspired Rankings.

MATLAB release MATLAB 7 (R14)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (8)
14 Nov 2007 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 ;-))

14 Nov 2007 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.

24 Jul 2006 Celia Sobrino

very smart

06 Jun 2005 Mukhtar Ullah

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

06 Feb 2005 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)

02 Feb 2005 Bruno Desart

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

29 Dec 2004 Mukhtar Ullah

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

29 Dec 2004 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
03 Jan 2005

removed one if else statement.

03 Jan 2005

rewritten as suggested by urs schwarz.

03 Jan 2005

a typo corrected.

03 Jun 2005

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

Contact us