Matlab Generate a probability histogram of the number of rol
[Matlab] Generate a probability histogram of the number of rolls required before a “7” appears while rolling two dice.
Here is a part of the code. I just need some parts that will track count the number of rolls it take until getting a sum of 7 from both die.
clear all
rolls= 10000;
for r=1:1:rolls
x=floor(6*rand(1)+1);
y=floor(6*rand(1)+1);
s(r)=x+y;
end
i=1:1:13;
[x,n]=hist(s,i)
bar(n,x)
stem(n,x)
axis([0 14 0 2000])
Solution
Clear all
rolls= 10000
for r= 1:1:rolls
P=0
x=floor (6*rand(1)+1)
Y=floor (6*rand(1)+1)
for I = 1:1:13
S(r)=x+y
if S(r)==7;
P=p+1
end
end
[x,n]=hist(s,I)
bar (n,x)
stem(n,x)
axis ([0 14 0 2000])
![[Matlab] Generate a probability histogram of the number of rolls required before a “7” appears while rolling two dice. Here is a part of the code. I just need s [Matlab] Generate a probability histogram of the number of rolls required before a “7” appears while rolling two dice. Here is a part of the code. I just need s](/WebImages/25/matlab-generate-a-probability-histogram-of-the-number-of-rol-1064113-1761556335-0.webp)