How to output all X values of bifurcation diagram for logistic map?
    7 views (last 30 days)
  
       Show older comments
    
I'm using the code below in matlab to produce a bifurcation diagram for the logistic map. I want to get every value of X for each a value but the array editor only shows one value of x for each a. Any help appreciated. Thanks
close all clear all
avalues=2.8:0.01:4;
N=100; a=avalues; x=0.1;
for n=1:.3*N x=a.*x.*(1-x); end
figure (9), hold on
for n=.3*N:N x=a.*x.*(1-x); plot(a,x,'.','MarkerSize',0.01) axis ([2.8 4 0 1]) end
hold off
0 Comments
Accepted Answer
  Fangjun Jiang
      
      
 on 10 Aug 2011
        x is over-written in every loop. If you want to keep a history and observe it, you can save it to a different array, X for example. The code below saves the x data in each iteration to a row in X.
close all 
clear all
avalues=2.8:0.01:4;
N=100; a=avalues; x=0.1;
X=zeros(N,length(a));
for n=1:.3*N 
    x=a.*x.*(1-x); 
    X(n,:)=x;
end
figure (9), hold on
for n=.3*N:N 
    x=a.*x.*(1-x); 
    X(n,:)=x;
    plot(a,x,'.','MarkerSize',0.01) 
    axis ([2.8 4 0 1]) 
end
hold off
More Answers (0)
See Also
Categories
				Find more on Nonlinear Analysis in Help Center and File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
