Code covered by the BSD License  

Highlights from
Statistical Learning Toolbox

from Statistical Learning Toolbox by Dahua Lin
Functions for statistical learning, pattern recognition and computer vision, covering many topics.

Description of slapplypca
Home > sltoolbox > subspace > slapplypca.m

slapplypca

PURPOSE ^

SLAPPLYPCA Applies PCA model to samples

SYNOPSIS ^

function Y = slapplypca(S, X)

DESCRIPTION ^

SLAPPLYPCA Applies PCA model to samples

 $ Syntax $
   Y = slapplypca(S, X)

 $ Arguments $
   - S:        the struct representing the PCA model 
   - X:        the sample matrix
   - Y:        the principal component vectors of the samples

 $ Description $
   - Y = slapplypca(S, X) applies the PCA model S to reduce the
     vector dimensions of samples X. It outputs the PCA features by Y.
     The formula for transform for each sample x in X is:
     y = S.P' * (x - S.vmean)

 $ History $
   - Created by Dahua Lin on May 1st, 2006
   - Modified by Dahua Lin, on Sep 10, 2006
       - change sladd to sladdvec

CROSS-REFERENCE INFORMATION ^

This function calls:
  • sladdvec SLADDVEC adds a vector to columns or rows of a matrix
  • raise_lackinput RAISE_LACKINPUT Raises an error indicating lack of input argument
This function is called by:

SOURCE CODE ^

0001 function Y = slapplypca(S, X)
0002 %SLAPPLYPCA Applies PCA model to samples
0003 %
0004 % $ Syntax $
0005 %   Y = slapplypca(S, X)
0006 %
0007 % $ Arguments $
0008 %   - S:        the struct representing the PCA model
0009 %   - X:        the sample matrix
0010 %   - Y:        the principal component vectors of the samples
0011 %
0012 % $ Description $
0013 %   - Y = slapplypca(S, X) applies the PCA model S to reduce the
0014 %     vector dimensions of samples X. It outputs the PCA features by Y.
0015 %     The formula for transform for each sample x in X is:
0016 %     y = S.P' * (x - S.vmean)
0017 %
0018 % $ History $
0019 %   - Created by Dahua Lin on May 1st, 2006
0020 %   - Modified by Dahua Lin, on Sep 10, 2006
0021 %       - change sladd to sladdvec
0022 %
0023 
0024 %% parse and verify input arguments
0025 if nargin < 2
0026     raise_lackinput('slapplypca', 2);
0027 end
0028 
0029 if ndims(X) ~= 2
0030     error('sltoolbox:invaliddims', ...
0031         'The sample matrix X should be a 2D matrix');
0032 end
0033 
0034 if size(X, 1) ~= S.sampledim
0035     error('sltoolbox:sizmismatch', ...
0036         'The sample dimension does not match that of PCA model');
0037 end
0038 
0039 %% compute
0040 Y = S.P' * sladdvec(X, -S.vmean, 1);

Generated on Wed 20-Sep-2006 12:43:11 by m2html © 2003

Contact us at files@mathworks.com