|
这个S函数里很多matlab语句不规范,我给该了一下,起码不报错了,逻辑上有没有错误我就不管了:
function [sys,x0,str,ts] = statefunc(t,x,u,flag,d)
A=[0 -1000000/335;100000 -100000/11];B=[1000000*d/335 0;0 100000];
E=[Vin*1000000/335 0];C=[0 1];D=[0 0];
switch flag,
case 0,
[sys,x0,str,ts]=mdlInitializeSizes;
case 2,
sys=[];
case 3,
sys=mdlOutputs(t,x,u);
case 4,
sys=[];
case 9,
sys=mdlTerminate(t,x,u);
case 1,
sys =mdlDerivatives(t,x,u,d);
otherwise
error(['Unhandled flag = ',num2str(flag)]);
end
function [sys,x0,str,ts]=mdlInitializeSizes
sizes = simsizes;
sizes.NumContStates = 1;
sizes.NumDiscStates = 0;
sizes.NumOutputs = 1;
sizes.NumInputs = 3;
sizes.DirFeedthrough = 1;
sizes.NumSampleTimes = 1;
sys = simsizes(sizes);
x0 = [0];
str = [];
ts = [0 0];
function sys=mdlDerivatives(t,x,u,d)
sys = [A*x+B*u+E*d];
function sys=mdlOutputs(t,x,u)
sys =[C*x+D*u];
function sys=mdlTerminate(t,x,u)
sys = [];
[ 本帖最后由 yf2002043227 于 2007-6-21 22:44 编辑 ] |
评分
-
1
查看全部评分
-
|