how to represent clusters graphicaly ?
1 回表示 (過去 30 日間)
古いコメントを表示
hi,i want to implement LDA algorithm ,for a first step i want to have a graphical representation of clusters for example:represent those 2 groups X1=[4,2;2,4;2,3;3,6;4,4] and X2=[9,10;6,8;9,5;8,7;10,8] and X3=[......] with different colors in one graph? like in picture
0 件のコメント
回答 (1 件)
Prateekshya
2024 年 10 月 14 日
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!
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Statistics and Machine Learning Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!