MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi
Learn moreOpportunities for recent engineering grads.
Apply TodayNew to MATLAB?
MATLAB Central > MATLAB Newsreader > Help with Monte Carlo Simulation 

Hi, I'm pretty new to matlab and I need to program a Monte Carlo simulation where 3 players have a number of coins. They decide to play a game where they flip coins and if the result ends up as 2 heads/tails and 1 tails/heads, the person with the 1 tails/heads result takes one coin from the other 2 player and keeps his or her coin. If the result is 3 heads or 3 tails then there is no change in any players coins. I need to figure out the average number of coin flips it takes to make one player go to zero. So far this is the code and I haven't tried to compute the average yet but my problem is that if I make n>1 then sometimes the code won't compute and it gets stuck at either "if X(3,1)==X(2,1)~=X(1,1)" which is line 29 or at line 50 which is just an "end" statement. If someone could help me out with what is wrong and any other advice it would be appreciated greatly. Thank you. 
Subject: Help with Monte Carlo Simulation From: Roger Stafford Date: 22 Oct, 2010 21:41:03 Message: 2 of 3 
"Rami " <akatsukiX2@gmail.com> wrote in message <i9sk00$ghf$1@fred.mathworks.com>... 
"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <i9t0df$ato$1@fred.mathworks.com>... 
A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.
Anyone can tag a thread. Tags are public and visible to everyone.