title: Matlab Coin Toss Simulation
body: <p>I have to write some code in Matlab that simulates tossing a coin 150 times. I have to count how many times the coin lands on heads and create a vector that gives a running percentage of the heads.  </p>
  
  <p>Then I have to make a table of the number of trials, random 'flips", and the running percentages of heads. I assume random "flips" means heads or tails for that trial.  </p>
  
  <p>I also have to create a line graph with trials on the x-axis and probabilities (percentages) on the y-axis. I'm assuming the percentages are just the percentage of getting heads. </p>
  
  <p>Sorry if this post was long. I figure giving the details now will make it easier to see what I was trying to do with the code. I didn't create the table or plot yet because I'm not even sure how to code for the actual problem. </p>
  
  <pre><code>NUM_TRIALS = 150;
  trials = 1:NUM_TRIALS;
  heads = 0;
  t = rand(NUM_TRIALS,1);
  percent_h = zeros(size(t));
  
  for i = trials
  
      if (t(i) &lt; 0.5)
          heads = heads + 1;
          percent_h = heads./trials; 
      end   
  end
  
  flips = t;
  
  disp('Number of Trials, Random flips, Heads Percentage')
  disp([trials', flips, percent_h'])
  plot(trials,percent_h)
  title('Trial Number vs. Percent Heads')
  xlabel('Trial number')
  ylabel('Percent Heads')
  </code></pre>