title: How can I plot these coin toss results in MATLAB?
body: <p>I'm writing a script to represent a coin flipped 100 times and I want to plot the percentage of occurrences for "heads" as these 100 trials progress. I can't seem to get the plot to display the number of heads/trials versus trials 1 through 100. The plot shows all of the heads/trials at the 100 point on the x-axis.</p>
  
  <p>This is the code I am using:</p>
  
  <pre><code>counter=0
  wins=0
  for k=1:100
      x=rand
      counter=counter+1
      if (x&lt;0.5)
          x_coin=0
      else
          x_coin=1
          wins=wins+1    
      end
      B(k)=counter
      C(k)=wins
      fraction=C.*(1./B)
      plot(k,fraction)
  end
  </code></pre>