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

📄 sfunhe.m

📁 文件是编辑好的m文件
💻 M
字号:
function  [sys,x0,str,ts] = sfunhe(t,x,u,flag,lb,ub,xi)
% SFUNHE An example M-File S-function for continuous systems.
%   This M-file is designed to be used as a template for other
%   S-functions. Right now it acts as an integrator. This template
%   is an example of a continuous system with no discrete components.
%
%   See sfuntmpl.m for a general S-function template.
%
%   See also SFUNTMPL.

%   Copyright 1990-2000 The MathWorks, Inc.
%   $Revision: 1.12 $

switch flag
  case 0,
                                                         % Initialization
    sys = mdlInitializeSizes(xi);

  case 1,                                                % Derivatives
    sys = mdlDerivatives(t,x,u,lb,ub);

  case 2,                                                % Discrete state update
    sys = mdlUpdate(t,x,u);

  case 3,
    sys = mdlOutputs(t,x,u);
  
  case 4,
    sys = mdlGetTimeOfNextVarHit(t,x,u);
  
  case 9,                                               
    sys = mdlTerminate(t,x,u);

  otherwise
    error(['unhandled flag = ',num2str(flag)]);
end
 function [sys,x0,str,ts]=mdlInitializeSizes(xi)
 sizes = simsizes;
 sizes.NumContStates = 1;
 sizes.NumDiscStates = 0;
 sizes.NumOutputs = 1;
 sizes.NumInputs =1;
 sizes.DirFeedthrough  =0;
 sizes.NumSampleTimes =1;
 sys= simsizes(sizes);
 x0=xi;
 str=[];
 ts=[0 0];
 
 function sys= mdlDerivatives(t,x,u,lb,ub)
 if (x<=lb & u<0)|(x>=ub & u>0),sys=0;else sys =u;end;
 
 function sys=mdlUpdate(t,x,u)
 sys=[];
 function sys=mdlOutputs(t,x,u)
 sys=x;
 function sys=mdlGetTimeOfNextVarHit(t,x,u)
 sampleTime=1;sys=t+sampleTime;
 function sys=mdlTerminate(t,x,u)
 sys=[];

⌨️ 快捷键说明

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