sifunction中多维输入的问题?
我最近碰到一个这样的问题.在编写s-function时.一般都是输出是多维的..但如果输入也是多维的..应该怎么写呢?比如说这个例题: y''(t)+25y'(t)=0.5r'(t) 程序如下:高手帮看下哪里错了?
function = twoinput(t,x,u,flag)
A=[0 1
0 -5];
B=[00
0 0.1];
C=;
switch flag,
case 0,
=mdlInitializeSizes(A,B,C);
case 1,
sys=mdlDerivatives(t,x,u,A,B);
case 2,
sys=mdlUpdate(t,x,u);
case 3,
sys=mdlOutputs(t,x,u,C);
case 4,
sys=mdlGetTimeOfNextVarHit(t,x,u);
case 9,
sys=mdlTerminate(t,x,u);
otherwise
error(['Unhandled flag = ',num2str(flag)]);
end
function =mdlInitializeSizes(A,B,C)
sizes = simsizes;
sizes.NumContStates= 1;
sizes.NumDiscStates= 0;
sizes.NumOutputs = 1;
sizes.NumInputs = 1;
sizes.DirFeedthrough = 1;
sizes.NumSampleTimes = 1; % at least one sample time is needed
sys = simsizes(sizes);
x0= ;
str = [];% str is always an empty matrix
ts= ;% initialize the array of sample times
function sys=mdlDerivatives(t,x,u,A,B)
sys = A*x+B*u;
function sys=mdlUpdate(t,x,u)
sys = [];
function sys=mdlOutputs(t,x,u,C)
sys = C*x;
function sys=mdlGetTimeOfNextVarHit(t,x,u)
sampleTime = 1; %Example, set the next hit to be one second later.
sys = t + sampleTime;
function sys=mdlTerminate(t,x,u)
sys = [];
% end mdlTerminate
[ 本帖最后由 16443 于 2008-6-30 11:11 编辑 ]
页:
[1]