|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
按照书上的一个S函数的例子写的,实现阶梯波的功能,可是一运行就会出错,请各位看看是什么问题?
function [sys,x0,str,ts] = jieti(t,x,u,flag,tTime,yStep)
% Dispatch the flag. The switch function controls the calls to
% S-function routines at each simulation stage.
switch flag,
case 0
[sys,x0,str,ts] = mdlInitializeSizes; % Initialization
case 3
sys = mdlOutputs(t,tTime,yStep); % Calculate outputs
case { 1, 2, 4, 9 }
sys = []; % Unused flags
otherwise
error(['Unhandled flag = ',num2str(flag)]); % Error handling
end;
% End of function timestwo.
%==============================================================
% Function mdlInitializeSizes initializes the states, sample
% times, state ordering strings (str), and sizes structure.
%==============================================================
function [sys,x0,str,ts] = mdlInitializeSizes
% Call function simsizes to create the sizes structure.
sizes = simsizes;
% Load the sizes structure with the initialization information.
sizes.NumContStates= 0;
sizes.NumDiscStates= 0;
sizes.NumOutputs= 1;
sizes.NumInputs= 0;
sizes.DirFeedthrough=0;
sizes.NumSampleTimes=1;
% Load the sys vector with the sizes information.
sys = simsizes (sizes);
%
x0 = []; % No continuous states
%
str = []; % No state ordering
%
ts = [0 0]; % Inherited sample time
% End of mdlInitializeSizes.
%==============================================================
% Function mdlOutputs performs the calculations.
%==============================================================
function sys = mdlOutputs(t,tTime,yStep)
i = find(tTime<=t);
sys =yStep(i(end));
% End of mdlOutputs. |
-
错误
|