Altering Matlab Code for a Logistic Map Cobweb Plot

In summary, there is a possibility of using MATLAB Online or the open source program Freemat to run the given code, but there may be differences in execution and restrictions in using MATLAB Online due to licensing. The alternative option is to use the free MATLAB Android app, but the speed may be affected by internet connectivity.
  • #1
Dustinsfl
2,281
5
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?
Matlab:
%%% 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);
 
Last edited by a moderator:
Physics news on Phys.org
  • #3
jedishrfu said:
One might be able to run this on the MATLAB Online service
MATLAB online is not free. You have to have a valid license to be able to use that. For instance, my student license entitles me to download MATLAB for offline use forever even if I do not renew (I won't get the updated version, only the one that was latest when the license expired). MATLAB Android app is, however, free to use, but the speed depends on your internet connectivity as the interpreter is on the server.
 
  • Like
Likes jedishrfu

FAQ: Altering Matlab Code for a Logistic Map Cobweb Plot

What is a logistic map cobweb plot?

A logistic map cobweb plot is a graphical representation of the behavior of a logistic map. It shows the relationship between the iterations of a logistic function and the corresponding values on a cobweb-like graph. This is commonly used in nonlinear dynamical systems to visualize the behavior of a population over time.

How do I alter Matlab code for a logistic map cobweb plot?

To alter Matlab code for a logistic map cobweb plot, you will need to make changes to the parameters and initial conditions of the logistic function. This can be done by modifying the equations and variables used in the code or by changing the values of the corresponding variables in the code.

What are the benefits of using a logistic map cobweb plot?

A logistic map cobweb plot provides a visual representation of the behavior of a population over time, allowing for a better understanding of how the population changes in response to different parameters and initial conditions. It can also help identify patterns and trends in the data that may not be apparent from just looking at numerical outputs.

Can I use a logistic map cobweb plot for any type of population?

Yes, a logistic map cobweb plot can be used for any population that follows a logistic growth pattern. This includes biological populations, economic models, and other nonlinear systems with similar behavior.

Are there any limitations to using a logistic map cobweb plot?

One limitation of using a logistic map cobweb plot is that it assumes a constant growth rate and does not account for other factors that may affect the population. Additionally, the plot may become less accurate as the number of iterations increases, as small errors can compound over time. It is important to consider these limitations when interpreting the results of the plot.

Similar threads

Replies
8
Views
944
Replies
4
Views
3K
Replies
1
Views
2K
Replies
2
Views
3K
Replies
10
Views
2K
Replies
1
Views
1K
Replies
1
Views
923
Back
Top