annotate toolboxes/FullBNT-1.0.7/KPMstats/mkPolyFvec.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 function p = mkPolyFvec(x)
wolffd@0 2 % MKPOLYFVEC Make feature vector by constructing 2nd order polynomial from input data
wolffd@0 3 % function p = mkPolyFvec(x)
wolffd@0 4 %
wolffd@0 5 % x(:,i) for example i
wolffd@0 6 % p(:,i) = [x(1,i) x(2,i) x(3,i) x(1,i)^2 x(2,i)^2 x(3,i)^2 ..
wolffd@0 7 % x(1,i)*x(2,i) x(1,i)*x(3,i) x(2,i)*x(3,i)]'
wolffd@0 8 %
wolffd@0 9 % Example
wolffd@0 10 % x = [4 5 6]'
wolffd@0 11 % p = [4 5 6 16 25 36 20 24 30]'
wolffd@0 12
wolffd@0 13 fvec = x;
wolffd@0 14 fvecSq = x.*x;
wolffd@0 15 [D N] = size(x);
wolffd@0 16 fvecCross = zeros(D*(D-1)/2, N);
wolffd@0 17 i = 1;
wolffd@0 18 for d=1:D
wolffd@0 19 for d2=d+1:D
wolffd@0 20 fvecCross(i,:) = x(d,:) .* x(d2,:);
wolffd@0 21 i = i + 1;
wolffd@0 22 end
wolffd@0 23 end
wolffd@0 24 p = [fvec; fvecSq; fvecCross];