As per my understanding of the question you would like to perform the auto-clustering on a dataset in MATLAB.
You can use the 'kmeans' function in MATLAB for clustering the dataset dynamically.
You can take help of the code below to start:
% Sample data generation (replace this with your actual data)
num_samples = 1000;
num_features = 2;
data = rand(num_samples, num_features);
% Parameters
num_clusters = 3; % Number of clusters
max_iterations = 100; % Maximum number of iterations
% Dynamic clustering loop
for iter = 1:max_iterations
% Perform k-means clustering
[cluster_labels, centroids] = kmeans(data, num_clusters);
% Update previous centroids
previous_centroids = centroids;
end
% Visualize clusters (for 2D data)
if num_features == 2
figure;
gscatter(data(:,1), data(:,2), cluster_labels);
hold on;
plot(centroids(:,1), centroids(:,2), 'kx', 'MarkerSize', 15, 'LineWidth', 3);
legend('Cluster 1', 'Cluster 2', 'Cluster 3', 'Centroids');
title('Dynamic K-Means Clustering');
hold off;
end
Please note that for using the 'kmeans' function you must have the license for 'Statistics and Machine Learning Toolbox'.
You can explore more about the 'kmeans' algorithm using the documentation link mentioned below:
I hope that this will help!