It's implemented in MATLAB in Statistical Toolbox as PRINCOMP function and PCA function. Check the documentation (follow the links ) for code examples. Many examples you can find with google.

You can also try a good PCA example on FileExchange:

http://www.mathworks.com/matlabcentral/fileexchange/16487-pca-demonstration-example