%rand('state',100*sum(clock)) clear all wns=0 wws=0; s1=1/3; s2=2/3; for i=1:10000; d=rand; %put the prize behind a door if d<=s1; door_prize=1; elseif d<=s2; door_prize=2; else door_prize=3; end choice=rand; %select a door if choice<=s1; door_sel=1; elseif choice<=s2; door_sel=2; else door_sel=3; end if door_prize==door_sel; %if you select the right door wns=wns+1; %you win if you do not switch WNS else wws=wws+1; %if you did not select the right door you win end % if you switch WWS end wws wns