Hello Zyad,
To graphically represent clusters using MATLAB, you can plot each group of data points with a different color. This will help you visualize how the data is distributed before applying the Linear Discriminant Analysis (LDA) algorithm. Here is how you can plot the example groups , , and with different colors:
% Define the data points for each group
X1 = [4, 2; 2, 4; 2, 3; 3, 6; 4, 4];
X2 = [9, 10; 6, 8; 9, 5; 8, 7; 10, 8];
X3 = [5, 5; 6, 5; 7, 6; 5, 7; 6, 6]; % Example data for X3
% Create a new figure
figure;
hold on; % Hold on to plot multiple groups on the same graph
% Plot each group with a different color and marker
plot(X1(:, 1), X1(:, 2), 'ro', 'MarkerSize', 8, 'DisplayName', 'Group X1'); % Red circles
plot(X2(:, 1), X2(:, 2), 'bs', 'MarkerSize', 8, 'DisplayName', 'Group X2'); % Blue squares
plot(X3(:, 1), X3(:, 2), 'g^', 'MarkerSize', 8, 'DisplayName', 'Group X3'); % Green triangles
% Add labels and legend
xlabel('Feature 1');
ylabel('Feature 2');
title('Graphical Representation of Clusters');
legend show; % Display the legend
grid on;
axis equal; % Ensure equal scaling of axes
hold off; % Release the hold on the current figure
The output of the code looks like:
I hope this helps!