1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Cobb web Matlab

  1. Feb 24, 2012 #1
    I found some Matlab code that works. However, I am not sure how to alter it for my needs.

    How can I make the code work for this:

    $$N_{t+1} = \frac{(1+r)N_t}{1+rN_t}$$

    What needs to be changed?
    Code (Text):
    %%% MAKES A COBWEB PLOT FOR A LOGISTIC MAP

    % compute trajectory
    a=3.0;          % parameter
    x0=0.2;         % Initial condition
    N=40;           % Number of iterations
    x(1) = x0;    
    for ic=1:N
     x(ic+1) = a*x(ic)*(1-x(ic));
    end




    % plot the map function and the line y=x
    clf;
    t = 0:0.01:1;
    plot(t,a*(t.*(1-t))); hold on;
     axis('square'); axis([0 1 0 1]);
     set(gca,'XTick',(0:0.1:1),'YTick',(0:0.1:1))
     grid on;


     fplot('1*y',[0 1],'r');



    %%%%%% STEP 3: PLOT COBWEB
     line([x(1) x(1)],[0 x(2)],'Color','g')
      plot(x(1), x(1),'ko');
     for ic=1:N-1
      line([x(ic) x(ic+1)],[x(ic+1) x(ic+1)],'Color','g')  
      line([x(ic+1) x(ic+1)],[x(ic+1) x(ic+2)],'Color','g')
      plot(x(ic+1), x(ic+1),'ko');
     end
     line([x(N) x(N+1)],[x(N+1) x(N+1)],'Color','g')
     
       %%%%%% STEP 4: SIGN THE PLOT
     at=text(0.1,0.82,['a=',num2str(a)]); set(at,'FontSize',12);
     
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?



Similar Discussions: Cobb web Matlab
  1. Matrices in MATLAB (Replies: 0)

  2. Matrix in matlab (Replies: 0)

  3. Matlab problem (Replies: 0)

Loading...