% extract usps

load usps
data = X;
datalabels = labels;
X = []; 
labels = [];
ndgt = [];                                  % number of samples of each digit
digits = [0,1,2,3,4,5,6,7,8,9]; 

for j = 1 : length(digits)
    idx = find(datalabels==digits(j));
    ndgt(j)= length(idx);
    labels = [labels;datalabels(idx)+1];    % change the labels from 0-9 to 1-10
    X = [X;data(idx,:)];
end

clear data datalabels idx j k; 