Question: Please fix my code for the following problem: My code is: % probability of heads on odd flip N = input ( ' Enter number

Please fix my code for the following problem:
My code is:
%probability of heads on odd flip
N = input('Enter number of games')
P = input('Enter the probability of heads')
game =0; %records games in an array
j =0; %index
win =0; %Accumulator
for i =1:N
Coin =0; %Coin starts at 0 aka tails
while Coin ~=1%keeps looping until coin =1
r = rand;
if r>= P
Coin =0;
else
Coin =1;
end
game(j)= Coin;
end
if mod(j,2)==1
win = win +1; %counts wins(heads)
end
game =0;
j=0+j;
end
win / N
Please fix my code for the following problem: My

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!