Here's an example of how to do Monte Carlo simulation for coin flips in Matlab:
main.m588 chars27 lines
This code generates a random sequence of 100 coin flips for each of 1000 simulations. It then calculates the number of heads for each simulation, and saves the result in an array. Finally, it plots a histogram of the results to show the distribution of the number of heads that came up in each simulation.
gistlibby LogSnag