comparison toolboxes/FullBNT-1.0.7/KPMtools/unaryEncoding.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:e9a9cd732c1e
1 function U = unaryEncoding(data, K)
2 % unaryEncoding Encode data(s) as a 1-of-K column vector
3 % function U = unaryEncoding(data, K)
4 %
5 % eg.
6 % If data = [3 2 2] and K=3,
7 % then U = [0 0 0
8 % 0 1 1
9 % 1 0 0]
10
11 if nargin < 2, K = max(data); end
12 N = length(data);
13 U = zeros(K,N);
14 ndx = subv2ind([K N], [data(:)'; 1:N]');
15 U(ndx) = 1;
16 U = reshape(U, [K N]);