I am trying to code a principal component analysis (PCA) on a dataset (8 samples , 2 features) and I can not plot the datapoints' projections on the eigenvector which provide the largest variace (eigenvector of the 1st principal component). The code is as following:
x=[1 1 2 0 5 4 5 3; 3 2 3 3 4 5 5 4]';
So I would like w2 to be the projections of the data set (hence eigenVector(:,2)*x) to the eigenvector of the highest-value eigenvalue. I think smth is wrong with this approach, I get somthing like inverse of the dataset (figure (2)). I multiply the k=1 dimension (eigenvector) with the dataset (w2=eigenVector(:,2)'.*x;).
Edit: This is the result that I cannot code
This is what i get when multiplying the eigenvector with the dataset.