dat = textread('digitsTrain.dat'); X = dat(:,1:end-1); y = dat(:,end); %Scale the image features to be floating point numbers from 0 to 1 X = double(X)./255; %Look at some digits [m,n] = size(X); imy = sqrt(n); imx = imy; %Find all 1's i1 = find(y == 1); %Grab the first one i1 = i1(1); im1 = reshape(X(i1,:),[imy imx])'; %Find all 2's i2 = find(y == 2); %Grab the first one i2 = i2(1); im2 = reshape(X(i2,:),[imy imx])'; %Find all 3's i3 = find(y == 3); %Grab the first one i3 = i3(1); im3 = reshape(X(i3,:),[imy imx])'; subplot(311); imagesc(im1); axis square; subplot(312); imagesc(im2); axis square; subplot(313); imagesc(im3); axis square; colormap gray;