% Script for Principal Components Analysis

clear all
load satdata

% Build matrix to pass to PRINCOMP.
mat = [m v pct];
[pcs,newdata,vars,t2] = princomp(mat);

% Plot new data, according to principal components.
plot(newdata(:,1),newdata(:,2),'+')

% Get list of states with most unusual results.
[t2sorted,ix] = sort(t2);
outix = ix(end-4:end);
outstates = names(outix,:)

% Use gname to plot names on component list.
% Try the upper right corner.  Hit RETURN when done.

gname(names)