clear all;
clc;

data = load('data.mat');
X = data.X;

P = size(X,1);

% normalizacja danych
X = (X - repmat (mean(X), P, 1)) ./ repmat (std(X), P, 1);

X = X';

[Y, W, R, R_hat, X_hat] = pca_transform(X, 2);

figure;
y1 = Y(1,:);
y2 = Y(2,:);
for i = 1:numel(y1)
    plot (y1(i), y2(i), 'rO');
    text (y1(i), y2(i), num2str (i),'HorizontalAlignment','center', 'VerticalAlignment', 'bottom', 'FontSize', 12)
    hold on;
end
xlabel ('PCA1');
ylabel ('PCA2');
title ('Plaszczyzna PCA(y_1,y_2)');
grid on;