title: Plotting cobweb diagram
body: <p>I am trying to plot a cobweb diagram of f(x)=r<em>x</em>(1-x), where r = 3. I am currently trying to use the following code:</p>
  
  <pre><code>function cobweb(f,a,b,x0,x1,N)
  x(1)=0.2; % plot orbit starting at x0
  for i=1:100
      x(i+1)= 3*x(i)*(x(i)+1);
      plot([x(i),x(i)],[x(i),x(i+1)]);
      hold on
      plot([x(i),x(i+1)],[x(i+1),x(i+1)]);
      hold on
  end
  hold off
  </code></pre>
  
  <p>But the resulting plot I get is completely wrong!</p>