File Exchange

image thumbnail

PSA: Part and Select Algorithm

version 1.1 (2.36 KB) by

Partitions the points X into K clusters and also returns the K more representative points.



View License

PSA Part and Select Algorithm for clustering

IDX = PSA(X,K) partitions the points in the N-by-P data matrix X
into K clusters. This partition minimizes the diameter, over all clusters, of
the maximum difference between points in a certain dimension P of X.
Rows of X correspond to points, columns correspond to variables.
Note: when X is a vector, PSA treats it as an N-by-1 data matrix,
regardless of its orientation. PSA returns an N-by-1 vector IDX
containing the cluster indices of each point. By default, PSA uses
squared Euclidean distances.

[IDX, MEMBERS] = PSA(X,K) returns the K more representative MEMBERS

[IDX, MEMBERS, MAX] = PSA(X,K) returns the K cluster maximum diameter difference
MAX for each cluster.

[IDX, MEMBERS, MAX, DIM] = PSA(X,K) returns the dimension of the K cluster
maximum diameter difference


X = [randn(30,2)+2.5;randn(30,2)-2.5];
subplot(1,2,1); plot(X(:,1),X(:,2),'bo');
IDX = psa(X,4);
subplot(1,2,2); plot(X(IDX==1,1),X(IDX==1,2),'bo');
hold on;

F = (exp(1-(rand(200,1)*(7)+1)/4*(linspace(-1,1,55)))+((rand(200,1)*(7)+1)*ones(1,55)).*sin((rand(200,1)*(7)+1)*(linspace(-1,1,55))));
plot(linspace(-1,1,55),F); xlim([-1 1]);
IDX = psa(F,6);
colors = {'b-' 'g-' 'r-' 'c-' 'm-' 'y-'};
for i=1:6 plot(linspace(-1,1,55),F(IDX==i,:),colors{i}); hold on; xlim([-1 1]); end

See also: kmeans

$Author: Alan de Freitas $ $Date: 2012/06/11 $ $Revision: 1.0 $
Copyright: 2012

Comments and Ratings (0)



Adding references

MATLAB Release
MATLAB 7.12 (R2011a)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video