pcares
gives you the residual, which is the error when subtracting the input with the reconstructed input. You can use the pca
command. It returns a MxM
matrix whose columns are the principle components. You can use the first k
of them to construct the feature, just do the following
X = bsxfun(@minus, A, mean(A)) * coeff(:, 1:k);
, where coeff
is what is returned from the pca
command. The function call with bsxfun
subtracts the mean (centers the data, as this is what pca
did when calculating the output coeff
).