作者ANUBISANKH (Pourquoi?)
看板NTUNL
標題[資訊] Logistic map 的 matlab 程式
時間Thu Jun 4 10:44:36 2009
幾年前寫的,會跑出兩個圖。第一個是把理論計算和實驗方法取得的 Lyapunov 指數隨
參數變化 plot 出來;第二個是把 fixed points 找出來,可看出隨參數變化有 period
doubling。
clc;
close all;
clear all;
I=100; % Iteration
n=5; % separation between pairs
A=1; % f(x)=ux(1-x),
B=4; %"u" from A to B
ai=0.001; % resolution of parameter "u"
f=round((B-A)/ai);
for u=1:f
U=u*ai;
x(u,1)=0.501;
% Iteration and calculating theoretical Lyapunov exponent
sum=0;
for i=1:I
x(u,i+1)=(U+A)*x(u,i)*(1-x(u,i)); % logistic map
sum=sum+log(abs((U+A)*(1-2*(1-x(u,i)))));
end
Lt(u)=sum/I;
% find closest points then calculate largest Lyapunov exponent
counter=0;
Lsum=0;
for i=2:I+1
if abs(x(u,1)-x(u,i))<0.05
if 0<abs(x(u,1)-x(u,i))
if i+n<I
if 0<abs(x(u,1+n)-x(u,i+n))
counter=counter+1;
L(counter)=(1/n)*log(abs(x(u,1+n)-x(u,i+n))/abs(x(u,1)-x(u,i)));
Lsum=Lsum+L(counter);
end
end
end
end
end
Lave(u)=Lsum/counter;
end
% plot theoretical and experimental data of L.E. together
figure(1)
plot([A+ai:ai:B],Lave,[A+ai:ai:B],Lt)
figure(2)
u=1:f;
i=round(0.7*I):I;
fixed=plot((u*ai+A),x(u,i),'.')
set(fixed,'MarkerSize',4.5);
--
"Bureaucrats!" Mallory scoffed cheerily. "They might known this would happen,
if they'd properly studied Catastrophist theory. It is a concatenation of
synergistic interactions; the whole system is on the PERIOD-DOUBLING ROUTE TO
CHAOS!"
----《Difference Engine》
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.228.192.166
1F:推 Keelungman:這個好!!! 06/04 23:03