📄 setting.m
字号:
%%%%%%%%%%%%%%%%% CHECKING%%%%%%%%%%%%%%%%%Remove spaces at the beginning and endodefun=rmspace(ODEfunction);OutputFile=rmspace(OutputFile);%Dimension of the linearized ODE;m=sqrt(linODEnum);n=fix(m);errCount=0;Missing='';if isempty(odefun) Missing=[sprintf(Missing) '"ODE function"' blanks(5)]; errCount=errCount+1;endif ( output & isempty(OutputFile) ) Missing=[sprintf(Missing) '"Output File"' blanks(5)]; errCount=errCount+1;endif isempty(InitialTime) Missing=[sprintf(Missing) '"Initial Time"' blanks(5)]; errCount=errCount+1;endif isempty(FinalTime) Missing=[sprintf(Missing) '"Final Time"' blanks(5)]; errCount=errCount+1;endif isempty(TimeStep) Missing=[sprintf(Missing) '"Time Step"' blanks(5)]; errCount=errCount+1;endif isempty(RelTol) Missing=[sprintf(Missing) '"Relative Tolerance"' blanks(5)]; errCount=errCount+1;endif isempty(AbsTol) Missing=[sprintf(Missing) '"Absolute Tolerance"' blanks(5)]; errCount=errCount+1;endif isempty(Discard) Missing=[sprintf(Missing) '"Iterations to be discarded"' blanks(5)]; errCount=errCount+1;endif isempty(UpdateStep) Missing=[sprintf(Missing) '"LEs updating step size"' blanks(5)]; errCount=errCount+1;endif isempty(ic) Missing=[sprintf(Missing) '"Initial condition(s)"' blanks(5)]; errCount=errCount+1;endif isempty(linODEnum) Missing=[sprintf(Missing) '"No. of linearized ODEs"' blanks(5)]; errCount=errCount+1;endif plot2 & isempty(ItrNum) Missing=[sprintf(Missing) '"No. of iterations for updating the plot"' blanks(2)]; errCount=errCount+1;elseif (plot1 & isempty(ItrNum)) ItrNum=1;endif errCount>0 if errCount>1 isare='parameters are'; else isare='parameter is'; end msg=['The following ' sprintf(isare) ' not specified or '... 'not in correct format:' sprintf('\n\n') ... sprintf(Missing)]; errordlg(msg,'ERROR','replace');elseif exist(odefun)~=2 msg=['Your ODE function ' '"' sprintf(odefun) '" '... 'does not exist!']; errordlg(msg,'ERROR','replace');elseif InitialTime>FinalTime msg='The initial time cannot be greater than the final time!'; errordlg(msg,'ERROR','replace');elseif InitialTime<0 msg='Initial time cannot be negative!'; errordlg(msg,'ERROR','replace');elseif (FinalTime<=0 | TimeStep<=0) msg='Time step and final time cannot be zero or negative!'; errordlg(msg,'ERROR','replace');elseif ( IntMethod==1 & FinalTime~=round(FinalTime) ) msg='For a discrete map, the final time must be an integer.'; errordlg(msg,'ERROR','replace');elseif TimeStep>(FinalTime-InitialTime) errordlg('The time step is too large!','ERROR','replace');elseif m~=n msg=['The number of linearized ODEs must be the square of'... ' an integer (i.e. 1, 4, 9, 16, 25, ..., n^2).']; errordlg(msg,'ERROR','replace');elseif ( Discard<0 | Discard~=round(Discard)) msg='The number of discarded iteration(s) can only be a positive integer or zero.'; errordlg(msg,'ERROR','replace');elseif (UpdateStep<=0 | UpdateStep~=round(UpdateStep) ) msg=['The number of step(s) for updating the Lyapunov exponents must'... ' be a positive integer.']; errordlg(msg,'ERROR','replace');elseif (minT>FinalTime) msg=['The number of time step(s) for updating the Lyapunov exponents or'... ' the number of discarded transient iterations is too large.']; errordlg(msg,'ERROR','replace');else Q0=eye(m); IC=[ic(:);Q0(:)]; if IntMethod>1 commandStr=['f0=feval(odefun,InitialTime,IC);',... 'problem=0;IClength=length(f0)-m*m;']; else commandStr=['f0=feval(odefun,IC);',... 'problem=0;IClength=length(f0)-m*m;']; end eval(commandStr,'problem=1;'); if problem msg=['Problem in ODE function "' sprintf(odefun) '" or ',... 'the no. of linearized ODEs you entered does not ',... 'match with that in the ODE function!']; errordlg(msg,'ERROR','replace'); eval(commandStr); elseif IClength<1 msg=['No. of linearized ODEs you entered is more than '... 'that in the ODE function "' sprintf(odefun) '".']; errordlg(msg,'ERROR','replace'); elseif length(f0)~=length(IC) msg=['Solving "' sprintf(odefun) '" requires ',... sprintf('an initial condition vector of length %d.',... IClength)]; errordlg(msg,'ERROR','replace'); elseif (plot2 & ItrNum<1 | ItrNum~=round(ItrNum)) msg=['The number of iterations for updating the plot must be'... ' a positive integer.']; errordlg(msg,'ERROR','replace'); elseif (plot2 & ItrNum>maxItr) msg=['The number of iterations for updating the plot is too large.'... ' For your case, the maximum number is ' sprintf(num2str(maxItr)) '.'... ' If you do not want to change this number, you can reduce the'... ' number of discarded transient iterations or the number of time'... ' steps for updating the Lyapunov exponents.']; errordlg(msg,'ERROR','replace'); else pass=1; if (output & exist(OutputFile)==2) %If the output file has already existed, warn the user. msg=['The file "' sprintf(OutputFile) '" has already existed.'... ' Overwrite it?']; decision=questdlg(msg,'Make a decision','Yes','No','Yes'); if strcmp(decision,'No'), pass=0; end end if pass %If no errors found, save the data and upload them onto the %'UserData' of the "Setting" button on the main window DATA=[ output, LEout, LEprecision, LDout, LDprecision, ... IntMethod, InitialTime, FinalTime, TimeStep, RelTol, ... AbsTol, plot1, plot2, ItrNum, LineColor, ... Discard, UpdateStep, linODEnum, ic]; MainHandles=get(HandlesList(24),'UserData'); set(MainHandles(4),'UserData',DATA); %Upload the output file and ODE function names %onto the 'UserData' of the "Start" button NAMES=char(OutputFile,ODEfunction); set(MainHandles(2),'UserData',NAMES); %Close the setting window close(gcf); %Label the axes and add a title with given strings xlabel(xLabel); ylabel(yLabel); title(Title); %Set axis ranges yRange=str2num(get(MainHandles(8),'String')); axis([InitialTime,FinalTime,yRange(1),yRange(2)]); set(MainHandles(7),'String',num2str([InitialTime,FinalTime])); end endend %End of CHECKING%--------------------------------------------------------------------function outStr=rmspace(inStr)%RMSPACE Function for removing the beginning and ending% spaces of a string% % OUTSTRING=RMSPACE(INSTRING) removes the spaces% at the beginning and end of the string INSTRING.% by Steve Wai Kam SIU, Feb. 23, 1998.%Remove spaces at the end of the stringoutStr=strcat(inStr);%Delete spaces at the beginning of the stringif ~isempty(outStr) while isspace(outStr(1)) outStr=outStr(2:length(outStr)); endend%-------------------------------------------------------------------function check(checkList,uncheckList)%CHECK Check function for check box or radio button% % CHECK(CHECKLIST) checks the radio buttons or % check boxes with handles in CHECKLIST.%% CHECK(CHECKLIST,UNCHECKLIST) checks the radio % buttons or check boxes with handles in CHECKLIST% and unchecks the ones with handles in UNCHECKLIST.%% CHECK([],UNCHECKLIST) unchecks the radio buttons% or check boxes with handles in CHECKLIST.% by Steve Wai Kam SIU, Feb. 19, 1998.if nargin<2 uncheckList=[];endif ~isempty(checkList) set(checkList,'Value',1);endif ~isempty(uncheckList) set(uncheckList,'Value',0);end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -