ID number could maybe be called index. If that helps you. To help you understand me, I want to make a link between two objects : the matrix called 'test' containing the coordinates of the 35000 observations I'm dealing with on the 2 first components found with the PCA (so its a 35000x2 double) (this is the object containing the index - ID number - of each data) and the clusters I found with the K-mean approach, that are contained in 2 objects :
- the idx2Region, which is a 1362110x1 double and
- the XGrid, which is a 1362110x2 double
Here's the two main codes that I used :
For the density plot :
figure()
plot(test(:,1),test(:,2),'+','MarkerSize',0.5)
xlabel('1st Principal Component')
ylabel('2nd Principal Component')
gname
And the k-mean alogirthm + ploting the 3 clusters :
x1 = min(test(:,1)):0.01:max(test(:,1));
x2 = min(test(:,2)):0.01:max(test(:,2));
[x1G,x2G] = meshgrid(x1,x2);
XGrid = [x1G(:),x2G(:)]; % Defines a fine grid on the plot
idx2Region = kmeans(XGrid,3,'MaxIter',1,'Start',C);...
% Assigns each node in the grid to the closest centroid
figure;
gscatter(XGrid(:,1),XGrid(:,2),idx2Region,...
[0,0.75,0.75;0.75,0,0.75;0.75,0.75,0],'..');
hold on;
plot(test(:,1),test(:,2),'k*','MarkerSize',5);
title 'Fisher''s Iris Data';
xlabel 'Petal Lengths (cm)';
ylabel 'Petal Widths (cm)';
legend('Region 1','Region 2','Region 3','Data','Location','Best');
hold off;
I can't seem to find a solution, but I'm sure it's not that hard, all the infos are here, I could do it manually with gname but it would take me years. Good luck and thank you all. B/R.

