Matlab编程之混沌系统李雅普诺夫指数分析

简介

     李雅普诺夫指数是衡量混沌系统的一个重要参数,下面截图是对其具体解释。

Matlab编程之混沌系统李雅普诺夫指数分析_第1张图片

 

Matlab编程之混沌系统李雅普诺夫指数分析_第2张图片

 

代码实现:

clc;
clear; 
 global kk;
 e=0
 ina1=0;
 final2=10;
 for kk=ina1:1:final2
    kk
InitialTime=0;	%Initial time
FinalTime=500;	%Final time
TimeStep=0.1;		%Time step
RelTol=1e-5;		%Relative tolerance
AbsTol=1e-6;		%Absolute tolerance
 
DiscardItr=150;	%Iterations to be discarded
UpdateStepNum=10;	%Lyapunov exponents updating steps
linODEnum=9;	%No. of linearized ODEs
ic=[1 1 1];	%Initial conditions
 
  
%Dimension of the linearized system (total: d x d ODEs)
d=sqrt(linODEnum);
%Initial conditions for the linearized ODEs
Q0=eye(d);
IC=[ic(:);Q0(:)];
ICnum=length(IC);		%Total no. of initial coniditions
%One iteration: Duration for updating the LEs
Iteration=UpdateStepNum*TimeStep;	
DiscardTime=DiscardItr*Iteration+InitialTime;
 

T1=InitialTime;
T2=T1+Iteration;
TSpan=[T1:TimeStep:T2];
%Absolute tolerance of each components is set to the same value
options=odeset('RelTol',RelTol,'AbsTol',ones(1,ICnum)*AbsTol);

%Initialize variables
n=0;		%Iteration counter
k=0;		%Effective iteration counter
		% (discarded iterations are not counted)
Sum=zeros(1,d);
xData=[];
yData=[];
  
A=[];
 
%Main loop
while (1)
   n=n+1;
   %Integration
   [t,X]=ode45('lyaphychaossf',TSpan,IC,options);    

  
   [rX,cX]=size(X);
   L=cX-linODEnum;      %No. of initial conditions for 
                        %the original system
   for i=1:d
      m1=L+1+(i-1)*d;
      m2=m1+d-1;
      A(:,i)=(X(rX,m1:m2))';
   end
   %QR decomposition
   if d>1
      %The algorithm for 1st-order system doesn't require
      %QR decomposition
      [Q,R]=qr(A);
      if T2>DiscardTime
         Q0=Q;
      else
         Q0=eye(d);
      end
   else
      R=A;
   end
         
  %in the following calculation, so discard this step.
   permission=1;
   for i=1:d
      if R(i,i)==0
         permission=0;
         break;
      end
   end
  %To determine the Lyapunov exponents
   if (T2>DiscardTime & permission)
      k=k+1;
      T=k*Iteration;
      TT=n*Iteration+InitialTime;
      %There are d Lyapunov exponents
      Sum=Sum+log(abs(diag(R))');
      Lambda=Sum/T;
      
 
      %Display the calculated Lyapunov exponents every 10 steps
      if rem(k,10)==0
         Lambda  % Lambda is the calculated Lyapunov exponents
         T2	 %Current time

         xData=[xData;TT]; %store the data to plot
         yData=[yData;Lambda];
      end
   end
        
   %If calculation is finished , exit the loop.
   if (T2>=FinalTime)
      %Show the final results (for making sure the final results being shown if DisplayStep>1)
      if (T2>DiscardTime & permission)
         Lambda
%         LD      %the Lyapunov dimension
      end
      break;
   end
   %Update the initial conditions and time span for the next iteration
      ic=X(rX,1:L);
      T1=T1+Iteration;
      T2=T2+Iteration;
      TSpan=[T1:TimeStep:T2];
   IC=[ic(:);Q0(:)];
end		%End of main loop
pp=length(yData(:,1));
e=e+1;
ll(e,1)= yData(pp,1);
ll(e,2)= yData(pp,2);
ll(e,3)= yData(pp,3);
%ll(e,4)= yData(pp,4);
end

bb=ina1:1:final2;
plot(bb, ll(:,1),bb, ll(:,2),bb, ll(:,3));grid;

 [t,X]=ode45('lyaphychaossf',TSpan,IC,options);    %词句调用的'lyaphychaossf'为一份.m文件,文件内容为chen系统的方程转换的雅克比行列式。

结果如下图:

可看出,此仿真程序仿真出的图示与理论分析结果一致。

Matlab编程之混沌系统李雅普诺夫指数分析_第3张图片 Chen混沌李雅普诺夫指数仿真图

你可能感兴趣的:(matlab编程)