How to Modify MATLAB Code for a New Cobweb Plot Equation?

In summary: 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,['r=',num2str(r)]); set(at,'FontSize',12);set(at,'HorizontalAlignment','right'); at=text(0.1,0.90,['x_0=',num2str(x0)]); set(at,'FontSize',12); set
  • #1
fauboca
158
0
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:
%%% 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);
 
Physics news on Phys.org
  • #2
set(at,'HorizontalAlignment','right'); at=text(0.1,0.90,['x_0=',num2str(x0)]); set(at,'FontSize',12); set(at,'HorizontalAlignment','right'); at=text(0.1,0.98,['N=',num2str(N)]); set(at,'FontSize',12); set(at,'HorizontalAlignment','right'); To make this code work for your equation:$$N_{t+1} = \frac{(1+r)N_t}{1+rN_t}$$you need to change the code as follows:% compute trajectoryr=3.0; % parameterx0=0.2; % Initial condition N=40; % Number of iterationsx(1) = x0; for ic=1:N x(ic+1) = (1+r)*x(ic)/(1+r*x(ic)); end% plot the map function and the line y=xclf;t = 0:0.01:1;plot(t,(1+r)*(t./(1+r*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
 

1. What is "Cobb web Matlab"?

"Cobb web Matlab" is a tool used in scientific research and data analysis. It is a specialized version of the programming language Matlab that is designed specifically for analyzing and visualizing complex networks, such as biological systems or social networks.

2. How is "Cobb web Matlab" different from regular Matlab?

"Cobb web Matlab" has additional functions and features that are specifically tailored for network analysis, such as network visualization tools and algorithms for finding important network nodes. It also has a different interface and workflow compared to regular Matlab.

3. Can I use "Cobb web Matlab" for any type of network analysis?

Yes, "Cobb web Matlab" can be used for a wide range of network analysis tasks, including analyzing biological networks, social networks, transportation networks, and many others. It is a versatile tool that can be adapted to different types of networks.

4. Do I need coding experience to use "Cobb web Matlab"?

Yes, "Cobb web Matlab" is a programming language and requires some coding experience. However, it has a user-friendly interface and provides tutorials and documentation to help users get started.

5. Is "Cobb web Matlab" free to use?

No, "Cobb web Matlab" is not a free tool. It is a commercial software and requires a license to use. However, many universities and research institutions have access to it through site licenses or subscriptions.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
4K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
875
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
949
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
865
  • Engineering and Comp Sci Homework Help
Replies
2
Views
810
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
553
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
Back
Top