source: prextra/expandd.m

Last change on this file was 5, checked in by bduin, 14 years ago
File size: 995 bytes
RevLine 
[5]1%EXPANDD Expand integer vector to a matrix occurrence table
2%
3%   A = EXPANDD(X,M)
4%
5% INPUT
6%   X   Vector containing positive integers
7%   M   Dimensionality of the returned matrix A
8%
9% OUTPUT
10%   A   Matrix
11%
12% DESCRIPTION
13% The vector X (e.g. numeric labels obtained from RENUMLAB) is expanded to
14% a matrix A of the size [LENGTH(X) x M] such that A(i,j) = 1 if X(i) == j
15% and A(i,j) = 0, otherwise.
16% As a result SUM(A) is a frequency table of j in X. MAX(A) is a 0/1 vector
17% indicating the occurrence of some j in X. FIND(MAX(A)) gives all j that
18% occur in X.
19%
20% SEE ALSO
21% RENUMLAB
22
23% Copyright: R.P.W. Duin, duin@ph.tn.tudelft.nl
24% Faculty of Applied Physics, Delft University of Technology
25% P.O. Box 5046, 2600 GA Delft, The Netherlands
26
27% $Id: expandd.m,v 1.1 2005/10/26 08:27:30 duin Exp $
28
29function a = expandd(x,m)
30
31        prtrace(mfilename);
32
33        x = x(:);
34        n = length(x);
35        if (nargin == 1)
36                m = max(x);
37        end
38        a = (x(:,ones(1,m)) == ones(n,1) * linspace(1,m,m));
39
40return;
Note: See TracBrowser for help on using the repository browser.