⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 let.m

📁 计算各种混沌系统李雅普洛夫指数的MATLAB 源程序。
💻 M
📖 第 1 页 / 共 2 页
字号:
function let(action,ODEfunction,DATA,AxisRange)%LET   Lyapunov Exponents Toolbox%%      To run the program, enter LET in MATLAB command window.%      Details of the program can be obtained by pressing%      the "Information" button in the startup window. The%      program information can also be found in files README.M,%      LETHELP.M and SETHELP.M.%      by Steve Wai Kam SIU, July 5, 1998.if nargin<1   clear;	%Clear all variables initially   clc;		%Clear the command window   action='Initialization'; else   %If it is a callback action, obtain  the handles of the   %GUI components stored in'UserData' of the main window.   MainHandles=get(gcf,'UserData');endswitch actioncase 'Initialization'   startlet;	%Show a startup window   case 'runLET'   %Default axis range   if nargin<4      AxisRange=[0,1000,-25,25];   end   %Font size of UI components   FontSize=8;   %Setup a GUI window and obtain the handles of GUI components   MainHandles=maingui(AxisRange,FontSize);   %Store the handles in "UserData" of the figure such that   %it can be accessed anywhere by using the "get" command.   set(gcf,'UserData',MainHandles);      %If no specified parameters are supplied, use default values.   if nargin<2         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   % Default Parameters for setting window   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     	      OutputFile='data.out';      %Default output file: data.out      output=0;                   %Don't check "Output File": 1="on", 0="off"      LEout=1;                    %Check "Lyapunov Exponents"      LDout=1;                    %Check "Lyapunov Dimension"      LEprecision=1;              %Precision of output values of the       LDprecision=1;              %  Lyapunov exponents and dimension                                    % are set to 1 (4 floating points).                                  % 2 means %.6f, 3 means %.8f, ...      ODEfunction='';     %No default ODE function      IntMethod=2;        %Integration method: 1=Discrete map, 2=ODE45, 3=ODE23	                       % 4=ODE113, 5=ODE23S, 6=ODE15S      InitalTime=0;       %Default initial time: 0      FinalTime=1000;     %Default final time: 1000      TimeStep=0.01;      %Default time step: 0.01      RelTol=1e-5;        %Default relative tolerance: 1E-5      AbsTol=1e-5;        %Default absolute tolerance: 1E-5      IC=[];              %No default initial coniditions      LODEnum=[];         %No. of linearized equation (default: none )         %PLOTTING OPTIONS:  Only one of them can be set "on" (i.e. 1)      plot1=1;            %Update the plot imediately      plot2=0;            %Update the plot every ... iterations      ItrNum=10;          %No. of iterations for updating the plot         %Line Colors      Blue=1; Black=2; Green=3; Red=4; Yellow=5; Magenta=6; Cyan=7;      LineColor=Blue;     %Default line color: Blue      Discard=100;        %Default transient iterations to be discarded: 100      UpdateSteps=10;     %Update the LEs every 10 time steps          %Save the default values and upload them onto the       %'UserData' of the "Setting" button      DATA=[output,       LEout, LEprecision,    LDout, LDprecision, ...          IntMethod,  InitalTime,   FinalTime, TimeStep, RelTol, ...            AbsTol,       plot1,       plot2,   ItrNum, LineColor, ...           Discard, UpdateSteps,     LODEnum,       IC];   else      %No specified output file for demo      OutputFile='';   end   set(MainHandles(4),'UserData',DATA);   %Upload the output file and ODE function names   NAMES=char(OutputFile,ODEfunction);   set(MainHandles(2),'UserData',NAMES);case 'stop'   %If "Stop" button is pressed,disable the button itself    %and enable the others.   set(MainHandles([2,4,13,15]),'Enable','On');   set(MainHandles(3),'Enable','Off');      %Set a flag to indicate "Stop" action is requested so    %that the program FINDLYAP knows during calculation    %and stops the process imediately.    set(MainHandles(3),'UserData',1);   %Note: FINDLYAP checks whether the "Stop" button is pressed   %before each iterationcase 'setting'   %Load the setting window   setting;case {'OnPressed','OffPressed'}   %If "On" is checked, uncheck "Off" and vice versa.   %MainHandles(5) is the handle of "On" radio button   %MainHandles(6) is the handle of "Off" radio button   OnIsOn=get(MainHandles(5),'Value');   OffIsOn=get(MainHandles(6),'Value');      if ( (strcmp(action,'OnPressed') & OnIsOn)| ...        (strcmp(action,'OffPressed') & ~OffIsOn) )      check(MainHandles(5),MainHandles(6));	%Check "On" and uncheck "Off"      grid on;											%Show grid lines   else      check(MainHandles(6),MainHandles(5));	%Check "Off" and uncheck "On"      grid off;										%Remove grid lines   endcase 'changeAxis'   %MainHandles(7) is the handle of the "X :" edit box   %MainHandles(8) is the handle of the "Y :" edit box   %Get values input by user   xRange=str2num(get(MainHandles(7),'String'));   yRange=str2num(get(MainHandles(8),'String'));      %Check whether the input values are in correct format   if ( all(size(xRange)==[1,2]) & all(size(yRange)==[1,2]) ...      	& xRange(1)<xRange(2) & yRange(1)<yRange(2) ...      	& xRange(1)~=xRange(2) & yRange(1)~=yRange(2))      axis([xRange,yRange]);		%Re-arrange the axis range.      %Save the data for restoring previous values if error occurs      set(MainHandles(7),'UserData',xRange);      set(MainHandles(8),'UserData',yRange);      axis('manual');				%Freeze the current axis-limits   else      %If error occurs, restore the original values      xRange=get(MainHandles(7),'UserData');   	yRange=get(MainHandles(8),'UserData');      set(MainHandles(7),'String',[num2str(xRange(1)) ', ' num2str(xRange(2))]);      set(MainHandles(8),'String',[num2str(yRange(1)) ', ' num2str(yRange(2))]);      msg=['Input must be a 1 x 2 numeric matrix'...            ' with format [minValue, maxValue], where'...            ' minValue < maxValue.'];      errordlg(msg,'ERROR','replace');   endcase 'drawLine'   %MainHandles(9) is the handle of the "Draw line at" edit box   str=get(MainHandles(9),'String');      y=str2num(str);  [ry,cy]=size(y);   LinesHandles=get(MainHandles(9),'UserData');   L=length(LinesHandles);   del=strcmp(lower(rmspace(str)),'del');   delall=strcmp(lower(rmspace(str)),'del*');   %Check whether the input values are in correct format   if (~isempty(y) & ry==1)      Y=[1;1]*y;      xRange=get(gca,'XLim');      X=xRange(:)*ones(1,length(y));      hold on; h=plot(X,Y,'k');      %Force MATLAB to draw imediately even if calculation is in progress      drawnow;					      							      %Add the new line handle(s), store them, and      %clear the string in the edit box.      newLinesHandles=[LinesHandles,h];      set(MainHandles(9),'UserData',newLinesHandles,'String','');   elseif ( L>=1 & del)      %Delete the previous drawn line      delete(LinesHandles(L));            %Remove the line handle stored in 'UserData', and      %clear the string in the edit box.      if L>1         set(MainHandles(9),'UserData',LinesHandles(1:L-1),'String','');      else         set(MainHandles(9),'UserData',[],'String','');      end   elseif ( L>=1 & delall)      % Delete all drawn lines      delete(LinesHandles);      set(MainHandles(9),'UserData',[],'String','');   elseif ( L<1 & (del | delall) )      msg='No more line can be deleted.';      errordlg(msg,'ERROR','replace');   else      msg=['Input must be a numeric number or row vector!'...            ' Use DEL to delete the previous drawn line or DEL*'...            ' to delete all drawn lines.'];      errordlg(msg,'ERROR','replace');   endcase 'plot'   %Get the line handles stored in 'UserData' of the    %"New Plot" button   LineHandles=get(MainHandles(13),'UserData');   [rL,cL]=size(LineHandles);   if ~isempty(LineHandles)   	%Get the current axis labels and title   	xLabel=get(get(gca,'xlabel'),'String');   	yLabel=get(get(gca,'ylabel'),'String');   	Title=get(get(gca,'Title'),'String');   	%Get the line color   	DATA=get(MainHandles(4),'UserData');   	Color=DATA(15);   	%Construct a look-up table for the line colors      COLORS='bkgrymc';      %Map the "Line color" pop-up menu position to the look-up table      LineColor=COLORS(Color);    	figure('Units','Normalized','Color',[1 1 1],'Name','Lyapunov Exponents Spectrum', ...   	'NumberTitle','off','Position',[0.1 0.1 0.8 0.8],'Tag','newplot');   	xlabel(xLabel); ylabel(yLabel); title(Title);        for i=1:rL           for j=1:cL              xData=get(LineHandles(i,j),'xData');              yData=get(LineHandles(i,j),'yData');              plot(xData,yData,LineColor);              hold on;           end        end        hold off;   else      errordlg('No data is available!','ERROR','replace');   endcase 'help'   helpwin('lethelp','LET Help Window');case 'start'   %When "Start" button is pressed, disable the "Start", 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -