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 slpcarecon
Home > sltoolbox > subspace > slpcarecon.m

slpcarecon

PURPOSE ^

SLPCARECON Reconstructs the samples in original space

SYNOPSIS ^

function X = slpcarecon(S, Y)

DESCRIPTION ^

SLPCARECON Reconstructs the samples in original space

 $ Syntax $
   - Xr = slpcarecon(S, Y)

 $ Arguments $
   - S:        the PCA model struct
   - Y:        the principal component features
   - Xr:       the reconstructed samples

 $ Description $
   - Xr = slpcarecon(S, Y) reconstructs the original samples approximately
     using the principal components Y. If the dimension of Y is less than
     the subspace dimension, the leading space dimensions will be used.

 $ History $
   - Created by Dahua Lin, on Aug 17, 2006
   - Modified by Dahua Lin, on Sep 10, 2006
       - replace sladd by sladdvec to increase efficiency

CROSS-REFERENCE INFORMATION ^

This function calls:
  • sladdvec SLADDVEC adds a vector to columns or rows of a matrix
This function is called by:

SOURCE CODE ^

0001 function X = slpcarecon(S, Y)
0002 %SLPCARECON Reconstructs the samples in original space
0003 %
0004 % $ Syntax $
0005 %   - Xr = slpcarecon(S, Y)
0006 %
0007 % $ Arguments $
0008 %   - S:        the PCA model struct
0009 %   - Y:        the principal component features
0010 %   - Xr:       the reconstructed samples
0011 %
0012 % $ Description $
0013 %   - Xr = slpcarecon(S, Y) reconstructs the original samples approximately
0014 %     using the principal components Y. If the dimension of Y is less than
0015 %     the subspace dimension, the leading space dimensions will be used.
0016 %
0017 % $ History $
0018 %   - Created by Dahua Lin, on Aug 17, 2006
0019 %   - Modified by Dahua Lin, on Sep 10, 2006
0020 %       - replace sladd by sladdvec to increase efficiency
0021 %
0022 
0023 %% parse and verify input
0024 
0025 if ~isstruct(S)
0026     error('sltoolbox:invalidarg', ...
0027         'S should be a PCA model struct');
0028 end
0029 
0030 if ~isnumeric(Y) || ndims(Y) ~= 2
0031     error('sltoolbox:invalidarg', ...
0032         'The features Y should be a 2D numeric matrix');
0033 end
0034 
0035 dy = size(Y, 1);
0036 if dy > S.feadim
0037     error('sltoolbox:sizmismatch', ...
0038         'The feature dimension of Y exceeds the subspace dimension preserved in model');
0039 end
0040 
0041 %% reconstruct
0042 
0043 if dy == S.feadim
0044     X = S.P * Y;
0045 else
0046     X = S.P(:, 1:dy) * Y;
0047 end
0048 
0049 X = sladdvec(X, S.vmean, 1);
0050 
0051 
0052 
0053

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

Contact us at files@mathworks.com