Cover how to load and reshape data

% Image set 4 = a cat

im=loadobjectimages(4,1:64,0.5);

[m,n,k] = size(im)

% Display just loaded images.
for count = 1:k
  imshow(im(:,:,count))
  drawnow;
end

% Make images into vector:

M = reshape(im,m*n,k);
% This works because Matlab stores matrices in column order, and we
% just collapsed the first two indices into one.

% One image can be recovered from a column vector into a 2D matrix:

I = reshape(M(:,5),m,n);
imshow(I)

% We need to work with doubles, but images (sometimes) come as uint8:
M = double(M);

Example on function fitting

Check out the example at Wikipedia.

PCA