Logistic 混沌模型的Matlab实现

上一篇 / 下一篇  2007-10-30 10:45:51

@'S_0E.z9p8{(w0% Author: Thomas Lee振动资讯r+N9W"?7@ ba0u0Lps;]

振动资讯Fd+Ar g#y`

% E-mail: lixf1979@126.com % Corresponding: School of Mathematics, Physics and Software Engineering, Lanzhou Jiaotong University, Lanzhou 730070, China 振动资讯Vb0U t_nA6Dq

%Progran Logistic bifurcation 1.m

m?%m p7A0

x=0.6;

!@0qD/o8}0

u=2.6:0.001:4;振动资讯3kl*V;US

for j=1:300振动资讯@+pK){y3w

    x=u.*(x-x.^2);振动资讯+}^aMF%~2R~

end振动资讯#mKj8^G.i;hB

for i=1:200

aZPSq P5d0

    x=u.*(x-x.^2);

+DH(t n{Z BT0

    %if i>=1900   振动资讯Zx#V7hwD*|8N

    %plot(u,x,'k.','markersize',1);

)C#F2[@([Qf[6p-T,S0

    hold on;

!o!`#E7}n8u1t l2pXF E0

    %end%振动资讯;y/f;K/is

end振动资讯8hB.a qU,c

 振动资讯n.dB7J4G/x s)[$a S

%Progran Logistic bifurcation 2.m振动资讯F/[qv3^"h?6PugA%cp

x=0.1;

m ~!P#{DLq_-X0

u=2.6:0.001:4;振动资讯'u M,\?Ei~#D*Jv2X,w

for j=1:300

o#i3x,k4? Rk$E0

    x=u.*(x-x.^2);振动资讯QSv Y;m0v

end振动资讯&D SfPs|

for i=1:2000振动资讯&VWftA!Qe*b&}K.Q3^-|

    x=u.*(x-x.^2);

+qiNQ Y [8l |0

  if i>=1900

S+Z(\ CFS@e0

    plot(u,x,'k.','markersize',1);

`&mC f:NC0

    hold on;

+oj"_4`!~0

   end

+a4]9dX9z1Sm0

end

(}:Cp_1i0

 

Q j;O t[0Q0~6l0

 

E5EzbS6Zjrr0

%Progran Logistic Phasespace.m

~!xU5H*Ku0

% solve and plot logistic map:振动资讯YAF h1{-]+\E

% x(n+1)=r*x(n)*(1-x(n))

V6KQN`,{h8Do2TT0

% number of steps:

9LH4C9?7P~T q0

N=100;振动资讯bFV"r8Fb@

% initial conditions:

6}S/G#g;T)Zjx+M|r0

x(1)=0.2;

^bC3q;Uj8a(}0

% parameter:

\u5B1pQ0@a0

 % r=3.8;  % chaos

y%NU7hH,CN0

% r=2.0;  % steady state

,B9dI0aQ0

% r=3.2;   % period 2振动资讯C/j.|7j_

r=3.5;   % period 4?振动资讯 kt$G B;\M7Cz0TB\|"]

for n=1:N

D,eCC%tY0

  x(n+1)=r*x(n)*(1-x(n));

%a]-uLzl q&g0

end振动资讯N3DP*g A ~9e"Y%XeCm

plot(x,'k')振动资讯+oYE4n(w`ken

title('logistic map')振动资讯#@&y0O*ox$@

xlabel('n')

{I%}1G*vp-]^0

ylabel('x(n)')

#V%@IR)@_g _L|0

figure

VE#d]c'IWd&A0

plot(x(2:N),x(1:N-1),'k.','markersize',5)振动资讯cP8yx/HB'N_)i

title('logistic map')振动资讯FZ&ptG4j;?

xlabel('x(n+1)')振动资讯-N9lZD ^nb?#i`2^

ylabel('x(n)')

[X:^+_R!i0

主要运行结果:振动资讯x k~,\+H;lu `

%r=3.8:产生的是混沌图相

(I$K0n0L'o!mWm0

%r=2.0时产生的是稳定状态

S*_ T1x f lQ@;W$l0

%r=3.2时,产生的是二周期的

)b7i4^{tc0

%r=3.5时,产生的是四周期的振动资讯 Q4^CH;e{L/] L{

 振动资讯8{"z!w!R V2F V

%Progran Logistic Lyapunov 1.m

6lYK8uFAa%b3mu0

%computes lyapunov exponent 振动资讯3U-WZ2n7dBQh~c

r = 4.0;

+q2i8G |E0{ h0

%%%%% first converge to attractor

3\;ZdD5\&O9S8{^0

x = rand;   %choose random initial data振动资讯^!]"m4k(R+KX&Do:P

for i=1:200;振动资讯y1Q~c g)[!B

   x = r*x*(1-x);     %apply logistic map

2G8s;KTKC RE9n0{0

end;振动资讯a(jg){}3G

%%%%% find (1/n) Sum ln(f'(x_i))  - limit should be lyapunov exponent振动资讯aW&T6M4G%tq!a

sum = 0;振动资讯{wYJ,OF C+o*h7z

for i=1:500;

:h;E2K;w(T{ T(}@&z.O0

    x = r*x*(1-x);     %logistic map振动资讯0\J eQ8P V8EK v#G

    sum = sum + log(abs(r - 2*r*x));振动资讯 a0va3`cKH

    sum/i;                                   %print out average

.A?G,N0HR0^0

    average(i) = sum/i;             %collect into vector for later plotting

:D*\.^.P%s^i0

end;

6g3L`C;Lbu1VQ0

plot(average,'k');      %plots sucessive averages so a trend can be observed振动资讯S(C2wj+uDt5Y}H

 振动资讯2R r[$c9S

%Progran Logistic Lyapunov 2.m振动资讯*wl&K:xx-B M

%computes lyapunov exponent

/tlg``c0

r =2.0:0.001: 4.0;振动资讯$AF6lt \)x7wvr

%%%%% first converge to attractor

(a~ ny-@0

x = 0.2;   %choose random initial data

yI.}Aj gu(D}0

for i=1:200;

[_ }!DdYo]0

   x = r.*x.*(1-x);     %apply logistic map

WcN%N$in2H0

end;

\,Q.?!c-f$G}:j)i0

%%%%% find (1/n) Sum ln(f'(x_i))  - limit should be lyapunov exponent

b:D/q%T8w/F0

sum = 0;

(XLL"\yGi[l0

for i=1:50000;振动资讯Z)~*oqq)q^P

    x = r.*x.*(1-x);     %logistic map振动资讯8MI$X7]Z$Qbmz

    sum = sum + log(abs(r - 2*r.*x));振动资讯 \ D5t@(aZ

    sum/i;                                   %print out average振动资讯f&Dysc${l

    average= sum/i;

xP7l?n0

    plot(r,average,'k');      %plots sucessive averages so a trend can be observed振动资讯-\Zh y i Di

%collect into vector for later plotting

NGG#K9Ng y0

end;振动资讯M|q ^exp X

hold on振动资讯$_M;t?"\Y |m5LsK Q

line(r,0)振动资讯*^ u5c:\X |8Q

 振动资讯k@ wKu

%Progran Logistic Cobweb 1.m

+yQ&b'U3[2PM~nt0

function logistic_cobweb(r,N)振动资讯*bJ ]dGz

% m-file to test iterative maps: implements cobweb construction, including

`(jJ3i3[RJA0

% transients, for logistic map振动资讯`4S[:\:|V.F9^/I y

yy = 0:0.05:1; ff = r.*yy.*(1-yy);

1m u9K2C9~^p"P8cy0

figure(1) ; clf ;

u]4JU6{i_ ]x0

plot(yy,ff,'-',yy,yy,'--')振动资讯3f!u8^[,{ E

hold on振动资讯:o2Iv`q!Rp

x = 0.1;          % Initial value振动资讯K/E cLpL8`5e#k

Xn = [];振动资讯E.f)N"T3st

%r = 2;           % Bifurcation parameter振动资讯!U!M+@&m#v4d(B&I2Z

x1 = r*x*(1-x);振动资讯FLf1?m4A.Q s

Xn = [Xn x1];振动资讯B(WVp?)a f"Z

plot([x x],[0 x1],'r-',[x x1],[x1 x1],'r-')

.d5fQ7V)W0

x = x1;振动资讯rrc)QXW#cLRA

for i = 2:N

+i/Q9g[/^4z7XP-QpM0

    x1 = r*x*(1-x);

'O?E \_f O T0

    Xn = [Xn x1];

`b4W8Eer0

    plot([x x],[x x1],'r-',[x x1],[x1 x1],'r-')

6s:N4^+[9?YM C0

    x = x1;振动资讯n;i(B{.S!_%[YT

end振动资讯xCTO"H-i'~ c

hold off

E0^+@ MY f IH0

〉〉logistic_cobweb(4,200)

M;? r&W;] @9_0

 振动资讯Dk!~mP$q.a{$n

%Progran Logistic Cobweb 2.m

fi%U X\0i'{#s4u0

%%  Renormalisation of logistic map f

+Zj Yzr2GNH$a?0

r=input('value of r:  ');

sN9Ern4qq0

clf reset

0[y I&k0z6_0

%%  The left-hand plot shows f and f^2振动资讯u$Q$O#x _-b#A

subplot(2,1,1)

_o7KcP}Q%dKal0

x0=0:0.025:1;振动资讯2UYn\kn

%% y=f(x0) and z=f^2(x0)振动资讯_{YF{!ux;l&@+JH

y=r.*x0.*(1-x0);

o$T,|1jKvHM%E0

z=r.*y.*(1-y);

[9c gL2O*|S0

%figure

4w9p"srdm{0

plot(x0,y,'k')振动资讯~9af"g7b#_,O

hold on振动资讯/ugY(cvby

plot(x0,x0,'k')

sXOlR(O O0

plot(x0,z,'k', 'LineWidth', 2)

P:tEJRit!V ox0

axis equal

S#|'T%@!X0

%% Now find where f^2(nxl)=1-(1/r)振动资讯M NA+E5M'G:Cv%e0RUQ }O

%% using the interval halving method振动资讯0Y/e8MXw2X8}5d

nxl=1-(1/r);振动资讯T}_-K)s @

g=inline('(r^2*x*(1-x)*(1-(r*x*(1-x))))-1+(1/r)','x','r');

HILy [}q0

xl=1-(1/r)+0.00001; xr=1;振动资讯 GNE$B jW%t

d=1;振动资讯R9D cCagy

while d>0.0001

nd(iM\#g0

   m=(xl+xr)/2;振动资讯`,?(ddKaP ] ?d

   if g(xl,r)*g(m,r)<0

[;bTz I#\f0

      xr=m;

H^ sW]F,K0Q$d?0

   else

O$kd.Fb0

      xl=m;

fGP eh|0

   end振动资讯0cr,fH"eq6rQ7T

   d=(xr-xl);振动资讯K^,J y6S1o!nD9VZ

end

`j,x!eaFNAC0

nxr=m;振动资讯(]/nyzE*uqZO9uG

%% Draw the little `invariant box'

3s+Q7P(Gd7fHxq z0

plot([nxr nxr],[nxr nxl],'k')振动资讯n,Z;_r(QOu

plot([nxr nxl],[nxl nxl],'k')振动资讯$V7G%eH/](Qf

plot([nxl nxr],[nxr nxr],'k')

v'ETTSLt0

plot([nxl nxl],[nxr nxl],'k')振动资讯g6I a/H*z

%xlim([0 1])振动资讯(YA:AX_/z b

%ylim([0 1])

b"F.Y yw!`$d^0

%%  On the right-hand side draw an expanded version of little box

X`o5B4`0

subplot(2,1,2)

1v*G t3}i#RJ0

x2=linspace(nxl,nxr,100);振动资讯4Muk9{%| ?#D(m

y2=r.*x2.*(1-x2); y2=r.*y2.*(1-y2);振动资讯P3ixn@\k-F(t fd

plot(x2,y2,'k','LineWidth', 2);振动资讯S/K"A s{ Q

hold on

h$bKL7x5l Ze0

plot(x2,x2,'k');振动资讯z I.k#l6v ]

axis equal振动资讯_/q8^m+{Uh

%xlim([nxl nxr])

6X5L,C0]Q#A0

%ylim([nxl nxr])振动资讯z*XK&?2D;i^

 振动资讯&MP\L6|3W;q


TAG:

liliangbiao的个人空间 引用 删除 liliangbiao   /   2008-01-15 21:49:27
原帖由lijh12于2008-01-08 15:05:12发表
不错,很不错

Thanks!
引用 删除 lijh12   /   2008-01-08 15:05:12
不错,很不错
liliangbiao的个人空间 引用 删除 liliangbiao   /   2007-11-02 16:43:35
You are welcome!
Any constructive comments, I would like!
shenyongjun的个人空间 引用 删除 shenyongjun   /   2007-11-01 12:29:21
错了,重来,应该是5分
shenyongjun的个人空间 引用 删除 shenyongjun   /   2007-11-01 12:28:44
1
长弓摄月 引用 删除 zhlong   /   2007-10-30 14:14:38
5
 

评分:0

我来说两句

显示全部

:loveliness: :handshake :victory: :funk: :time: :kiss: :call: :hug: :lol :'( :Q :L ;P :$ :P :o :@ :D :( :)

关于作者