Search code examples
matlab3d2dpcasvd

Matlab 3D to 2D with Principal Component Analysis (PCA)


I want to do PCA on this 3D matrix:

data=[5 4 5; 5 3 0; 1 2 2];

PCA should return two components, like 3D to 2D, to plot the data on a graph.

What I've tried:

data=[5 4 5; 5 3 0; 1 2 2];
x= princomp(data');
x

But 'x' returns a 3D, instead of a 2D matrix.


Solution

  • I don’t think you have a 3D result. I think you have a result of dimension pxp when your data is nxp, which is normal. See the doc.