www.pudn.com > baojiading.rar > guessnum.asv, change:2009-03-04,size:685b


function guessnum %This program for guess a number,which is less then integer of 127 
clear 
i1=1:2:127 
A(:,:,1)=reshape(i1,8,8); 
i2=1:2:63; 
A2=[2*i2;2*i2+1]; 
A(:,:,2)=reshape(A2,8,8); 
i4=1:2:31; 
A3=[4*i4;4*i4+1;4*i4+2;4*i4+3]; 
A(:,:,3)=reshape(A3,8,8); 
i8=1:2:15; 
A(:,:,4)=[8*i8;8*i8+1;8*i8+2;8*i8+3;8*i8+4;8*i8+5;8*i8+6;8*i8+7]; 
A5=[16:31,48:63,80:95,112:127]' 
A(:,:,5)=reshape(A5,8,8); 
A6=[32:63,96:127]'; 
A(:,:,6)=reshape(A6,8,8); 
A7=[64:127]'; 
A(:,:,7)=reshape(A7,8,8); 
A 
V=input('please input a vector as[0,0,1,0,1,0],which matrix has your number set 1 else set 0\n') 
S=sum(V(1)+2*V(2)+4*V(3)+8*V(4)+16*V(5)+32*V(6)+64*V(7)); 
fprintf('your number is %d\n',S)