function v=cardrun num=50; p1=[80,75,50]; k=randperm(3); p=p1(k(1)); numones=round(num*(p/100)) d1=ones(1,numones); d2=zeros(1,num-numones); D=[d1,d2]; idx=randperm(num); D=D(idx); D=D(:); choices=zeros(num,1); win=0; for i=1:num b=D(i); a=input('Will the next number be 0 or 1\n\n'); if length(a)==0 fprintf('Please input a 0 or a 1\n'); a=input('Will the next number be a 0 or a 1\n\n'); end choices(i)=a; if a==b fprintf('You won! \n\n'); win=win+1; else fprintf('Sorry, that was incorrect. Please try again...\n'); end end fprintf('Game over\n'); y(1)=p; y(2)=100*(win/num); v.win=y; v.choice=choices; v.cards=D;