Basically it's correct. Note that in princomp
rows of input correspond to observations, and columns to variables.
To illustrate your procedure,
IMGS = rand(1000,784);
[COEFF, SCORE] = princomp(IMGS);
To prove the use of function is correct, you can try to recover the original image,
recovered_IMGS = SCORE / COEFF + repmat(mean(IMGS,1), 1000, 1);
then IMGS - recovered_IMGS
will give you the zero matrix (within numerical error).
To use only the first 100 features, you can just
for i=101:784
SCORE(:,i) = zeros(1000,1);
end
Then use the same code to recover the images:
recovered_IMGS_100 = SCORE / COEFF + repmat(mean(IMGS,1), 1000, 1);
Or you can, as you mentioned , created another 100 x 1000 array to achieve the same result.