How to output all X values of bifurcation diagram for logistic map?

2 vues (au cours des 30 derniers jours)
Sinead
Sinead le 10 Août 2011
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

Réponse acceptée

Fangjun Jiang
Fangjun Jiang le 10 Août 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

Plus de réponses (0)

Catégories

En savoir plus sur Nonlinear Analysis dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by