load('mnist_uint8.mat');
 
 test= zeros([1000 1]); 
 for i=1:1000,
     for j=1:10,
         if (test_y(i,j)==1)
            test(i,1)=j-1;
         end
     end
 end

 train= zeros([6000 1]); 
 for i=1:6000,
     for j=1:10,
         if (train_y(i,j)==1)
            train(i,1)=j-1;
         end
     end
 end

 for k=1:10,
 	classified=zeros([1000 1]);
 	classified=knnclassify(test_x(1:1000,:),train_x(1:6000,:),train,k);
	error=0;
	for i=1:1000,
		if(classified(i,1)~=test(i,1))
			error=error+1;
		end
	end
	erptg(k)=((error*100)/1000);
end
 z=find(erptg);plot(z,erptg(z),'--rs','LineWidth',2,...
                'MarkerEdgeColor','k',...
                'MarkerFaceColor','g',...
                'MarkerSize',10);grid on;
xlabel('k, number of nearest neighbours ','FontSize',16);
ylabel('Erptg , Error in Percentage ','FontSize',16);