# PCA of hyperspectral image data

I have some hyperspectral image data similar to this, and I want to do a PCA on it. The problem: I've never done a PCA, and its specially difficult for me to do it on 3D data.

How can I do it in MATLAB or R? [See also Analyzing 3D data: What can be done? ]

-

One simple way to do it is to transform your 3D data into a vector. This is a bit rough but often works fine in practice. Then you can use the prcompfunction from the R base package to compute PCA.