123456789101112131415161718192021222324252627 |
- function plotProgresskMeans(X, centroids, previous, idx, K, i)
- %PLOTPROGRESSKMEANS is a helper function that displays the progress of
- %k-Means as it is running. It is intended for use only with 2D data.
- % PLOTPROGRESSKMEANS(X, centroids, previous, idx, K, i) plots the data
- % points with colors assigned to each centroid. With the previous
- % centroids, it also plots a line between the previous locations and
- % current locations of the centroids.
- %
- % Plot the examples
- plotDataPoints(X, idx, K);
- % Plot the centroids as black x's
- plot(centroids(:,1), centroids(:,2), 'x', ...
- 'MarkerEdgeColor','k', ...
- 'MarkerSize', 10, 'LineWidth', 3);
- % Plot the history of the centroids with lines
- for j=1:size(centroids,1)
- drawLine(centroids(j, :), previous(j, :));
- end
- % Title
- title(sprintf('Iteration number %d', i))
- end
|