📄 nonlin.m
字号:
function [ret,x0,str]=nonlin(t,x,u,flag);
%NONLIN is the M-file description of the SIMULINK system named NONLIN.
% The block-diagram can be displayed by typing: NONLIN.
%
% SYS=NONLIN(T,X,U,FLAG) returns depending on FLAG certain
% system values given time point, T, current state vector, X,
% and input vector, U.
% FLAG is used to indicate the type of output to be returned in SYS.
%
% Setting FLAG=1 causes NONLIN to return state derivitives, FLAG=2
% discrete states, FLAG=3 system outputs and FLAG=4 next sample
% time. For more information and other options see SFUNC.
%
% Calling NONLIN with a FLAG of zero:
% [SIZES]=NONLIN([],[],[],0), returns a vector, SIZES, which
% contains the sizes of the state vector and other parameters.
% SIZES(1) number of states
% SIZES(2) number of discrete states
% SIZES(3) number of outputs
% SIZES(4) number of inputs.
% For the definition of other parameters in SIZES, see SFUNC.
% See also, TRIM, LINMOD, LINSIM, EULER, RK23, RK45, ADAMS, GEAR.
% Copyright (c) 1990-94 by The MathWorks, Inc.
% Note: This M-file is only used for saving graphical information;
% after the model is loaded into memory an internal model
% representation is used.
% the system will take on the name of this mfile:
sys = mfilename;
new_system(sys)
simver(1.3)
if(0 == (nargin + nargout))
set_param(sys,'Location',[9,62,393,742])
open_system(sys)
end;
set_param(sys,'algorithm', 'Euler')
set_param(sys,'Start time', '0.0')
set_param(sys,'Stop time', '999999')
set_param(sys,'Min step size', '0.0001')
set_param(sys,'Max step size', '0.1')
set_param(sys,'Relative error','1e-3')
set_param(sys,'Return vars', '')
add_block('built-in/Saturation',[sys,'/','Saturation'])
set_param([sys,'/','Saturation'],...
'position',[150,575,205,615])
add_block('built-in/Look Up Table',[sys,'/','Look Up Table'])
set_param([sys,'/','Look Up Table'],...
'position',[150,505,205,545])
add_block('built-in/Relay',[sys,'/','Relay'])
set_param([sys,'/','Relay'],...
'position',[150,440,205,480])
add_block('built-in/Rate Limiter',[sys,'/','Rate Limiter'])
set_param([sys,'/','Rate Limiter'],...
'position',[150,375,205,415])
add_block('built-in/Dead Zone',[sys,'/','Dead Zone'])
set_param([sys,'/','Dead Zone'],...
'position',[150,310,205,350])
add_block('built-in/Backlash',[sys,'/','Backlash'])
set_param([sys,'/','Backlash'],...
'position',[150,250,205,290])
add_block('built-in/Note',[sys,'/','Nonlinear'])
set_param([sys,'/','Nonlinear'],...
'position',[180,25,181,26])
add_block('built-in/Note',[sys,'/','Library'])
set_param([sys,'/','Library'],...
'position',[180,40,181,41])
add_block('built-in/Abs',[sys,'/','Abs'])
set_param([sys,'/','Abs'],...
'position',[135,65,165,85])
add_block('built-in/Product',[sys,'/','Product'])
set_param([sys,'/','Product'],...
'position',[190,90,220,110])
add_block('built-in/Signal Generator',[sys,'/','Signal'])
set_param([sys,'/','Signal'],...
'Peak','1.000000',...
'Peak Range','1.000000',...
'Freq','1.000000',...
'Freq Range','1.000000',...
'Wave','Sin',...
'Units','Rads',...
'position',[25,283,70,317])
add_block('built-in/Scope',[sys,'/','Fcn Scope'])
set_param([sys,'/','Fcn Scope'],...
'Vgain','1.500000',...
'Hgain','20.000000',...
'Vmax','3.000000',...
'Hmax','40.000000',...
'Window',[402,200,647,328],...
'position',[285,140,310,170])
add_block('built-in/Fcn',[sys,'/','Fcn'])
set_param([sys,'/','Fcn'],...
'Expr','sin(u);',...
'position',[160,145,190,165])
add_block('built-in/MATLAB Fcn',[sys,'/','MATLAB Fcn'])
set_param([sys,'/','MATLAB Fcn'],...
'position',[145,187,205,223])
add_block('built-in/Scope',[sys,'/','MATLAB Fcn Scope'])
set_param([sys,'/','MATLAB Fcn Scope'],...
'Vgain','1.500000',...
'Hgain','20.000000',...
'Vmax','3.000000',...
'Hmax','40.000000',...
'Window',[399,289,644,417],...
'position',[285,190,310,220])
add_block('built-in/Scope',[sys,'/','Backlash Scope'])
set_param([sys,'/','Backlash Scope'],...
'Vgain','1.500000',...
'Hgain','20.000000',...
'Vmax','3.000000',...
'Hmax','40.000000',...
'Window',[401,359,646,487],...
'position',[285,255,310,285])
add_block('built-in/Scope',[sys,'/','Dead Zone Scope'])
set_param([sys,'/','Dead Zone Scope'],...
'Vgain','1.500000',...
'Hgain','20.000000',...
'Vmax','3.000000',...
'Hmax','40.000000',...
'Window',[404,434,649,562],...
'position',[285,315,310,345])
add_block('built-in/Scope',[sys,'/','Rate Scope'])
set_param([sys,'/','Rate Scope'],...
'Vgain','1.500000',...
'Hgain','20.000000',...
'Vmax','3.000000',...
'Hmax','40.000000',...
'Window',[405,508,650,636],...
'position',[285,380,310,410])
add_block('built-in/Scope',[sys,'/','Relay Scope'])
set_param([sys,'/','Relay Scope'],...
'Vgain','1.500000',...
'Hgain','20.000000',...
'Vmax','3.000000',...
'Hmax','40.000000',...
'Window',[409,571,654,699],...
'position',[285,445,310,475])
add_block('built-in/Scope',[sys,'/','Look Up Scope'])
set_param([sys,'/','Look Up Scope'],...
'Vgain','1.500000',...
'Hgain','20.000000',...
'Vmax','3.000000',...
'Hmax','40.000000',...
'Window',[407,641,652,769],...
'position',[285,510,310,540])
add_block('built-in/Scope',[sys,'/','Saturation Scope'])
set_param([sys,'/','Saturation Scope'],...
'Vgain','1.500000',...
'Hgain','20.000000',...
'Vmax','3.000000',...
'Hmax','40.000000',...
'Window',[407,711,652,839],...
'position',[285,580,310,610])
add_block('built-in/Scope',[sys,'/','Abs Product Scope'])
set_param([sys,'/','Abs Product Scope'],...
'Vgain','1.500000',...
'Hgain','20.000000',...
'Vmax','3.000000',...
'Hmax','40.000000',...
'Window',[399,126,644,254],...
'position',[285,85,310,115])
add_line(sys,[75,300;75,270;140,270])
add_line(sys,[75,300;75,330;140,330])
add_line(sys,[75,300;75,205;135,205])
add_line(sys,[75,300;75,155;150,155])
add_line(sys,[75,300;75,105;180,105])
add_line(sys,[75,300;75,75;125,75])
add_line(sys,[75,300;75,395;140,395])
add_line(sys,[75,300;75,460;140,460])
add_line(sys,[75,300;75,525;140,525])
add_line(sys,[75,300;75,595;140,595])
add_line(sys,[210,595;275,595])
add_line(sys,[210,525;275,525])
add_line(sys,[210,460;275,460])
add_line(sys,[210,395;275,395])
add_line(sys,[210,330;275,330])
add_line(sys,[210,270;275,270])
add_line(sys,[210,205;275,205])
add_line(sys,[195,155;275,155])
add_line(sys,[170,75;170,95;180,95])
add_line(sys,[225,100;275,100])
% Return any arguments.
if (nargin | nargout)
% Must use feval here to access system in memory
if (nargin > 3)
if (flag == 0)
eval(['[ret,x0,str]=',sys,'(t,x,u,flag);'])
else
eval(['ret =', sys,'(t,x,u,flag);'])
end
else
[ret,x0,str] = feval(sys);
end
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -