categories = ['F1';'F2';'F3';'F4';'F5';'F6';'F7';'F8'];
load('MAT_ALL.mat')
[coefforth,score,~,~,explainedVar] = pca(MaT_All(:,9:16));
load('DataGroup.mat')
clusters = DataGroup(:,20);
[coefforth,score,~,~,explainedVar] = pca(MaT_All(:,9:16));
figure()
h = biplot([coefforth(:,1) coefforth(:,2)],'Scores',[score(:,1) score(:,2)],'Varlabels',categories);
hID = get(h, 'tag');
hPt = h(strcmp(hID,'obsmarker'));
grp = findgroups(clusters);
grp(isnan(grp)) = max(grp(~isnan(grp)))+1;
grpID = 1:max(grp);
clrMap = lines(length(unique(grp)));
for i = 1:max(grp)
set(hPt(grp==i), 'Color', clrMap(i,:), 'DisplayName', sprintf('Cluster %d', grpID(i)))
end
[~, unqIdx] = unique(grp);
legend(hPt(unqIdx))
Best Answer