You are on page 1of 3

TRABAJO DE LABORATORIO

clear
close all
clc
cont=zeros(11,1);
for k = 1:20000

% 20000 juegos

x1 = rand(1,1);
x2 = rand(1,1);
%entre 0 y 1
x1 = (6.499 - 0.501)*x1 + 0.501;
x2 = (6.499 - 0.501)*x2 + 0.501;
%entre 0.501 y 6.499
x1 = round(x1);
x2 = round(x2);
x=x1+x2;
%dado: 1,2,3,4,5,6
if(x==2)
cont(1,1)=cont(1,1)+1;
else if(x==3)
cont(2,1)=cont(2,1)+1;
else if(x==4)
cont(3,1)=cont(3,1)+1;
else if(x==5)
cont(4,1)=cont(4,1)+1;
else if(x==6)
cont(5,1)=cont(5,1)+1;
else if(x==7)
cont(6,1)=cont(6,1)+1;

else if(x==8)
cont(7,1)=cont(7,1)+1;
else if(x==9)
cont(8,1)=cont(8,1)+1;
else if(x==10)
cont(9,1)=cont(9,1)+1;
else if(x==11)
cont(10,1)=cont(10,1)+1;
else if(x==12)
cont(11,1)=cont(11,1)+1;
end
end
end
end
end
end
end
end
end
end
end
end
cont=cont/20000;
sumadados=2:12;
sumadados=sumadados';
figure(1);
bar(sumadados , cont,'w');
grid;

You might also like