|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
function [sys,x0,str,ts]=skdj(t,x,u,flag)
switch flag,
case 0,
[sys,x0,str,ts]=mdlInitializeSizes;
case 1,
sys=mdlDerivatives(t,x,u);
case 3,
sys=mdlOutputs(t,x,u);
case {2,4,9},
sys=[];
otherwise
error(['Unhandled flag=',num2str(flag)]);
end
function [sys,x0,str,ts]=mdlInitializeSizes
sizes=simsizes;
sizes.NumContStates = 7;
sizes.NumDiscStates = 0;
sizes.NumOutputs = 1;
sizes.NumInputs = 7;
sizes.DirFeedthrough = 1;
sizes.NumSampleTimes = 1;
sys = simsizes(sizes);
x0 = zeros(7,1);
str = [];
ts = [0 0];
function sys=mdlDerivatives(t,x,u)
Pa=2;
La=0.1561;
Ra=2.650;
Lar=0.15557;
Rar=2.521;
Lma=01451;
Pb=3;
Lb=0.1383;
Rb=3.400;
Lbr=0.1380;
Rbr=2.9200;
Lmb=0.1274;
J=0.2;
Tm=0;
Rc=0.05;
A=[La 0 0 0 Lma 0 0;0 La 0 0 0 Lma 0;0 0 Lb 0 -Lmb 0 0;0 0 0 Lb 0 Lmb 0;Lma 0 -Lmb 0 Lar+Lbr 0 0;0 Lma 0 Lmb 0 Lar+Lbr 0;0 0 0 0 0 0 1];
B=[1 0 0 0 0 0;0 1 0 0 0 0;0 0 1 0 0 0;0 0 0 1 0 0;0 0 0 0 0 0;0 0 0 0 0 0;0 0 0 0 0 0];
C=[-Ra Pa*La*x(7) 0 0 0 Pa*Lma*x(7) 0;-Pa*La*x(7) -Ra 0 0 -Pa*Lma*x(7) 0 0;0 0 -Rb Pb*Lb*x(7) 0 Pb*Lmb*x(7) 0;0 0 -Pb*x(7)*Lb -Rb Pb*x(7)*Lmb 0 0;0 0 0 0 -Rar-Rbr 0 0;0 0 0 0 0 -Rar-Rbr 0;0 0 0 0 0 0 -Rc/J];
x=[x(1);x(2);x(3);x(4);x(5);x(6);x(7)];
u=[u(1);u(2);u(3);u(4);0;0];
sys=inv(A)*C*x+inv(A)*B*u;
function sys=mdlOutputs(t,x,u)
Pa=2;
La=0.1561;
Ra=2.650;
Lar=0.15557;
Rar=2.521;
Lma=01451;
Pb=3;
Lb=0.1383;
Rb=3.400;
Lbr=0.1380;
Rbr=2.9200;
Lmb=0.1274;
J=0.2;
Tm=0;
Rc=0.05;
Te=Pa*Lma*(x(2)*x(5)-x(6)*x(1))+Pb*Lmb*(-x(4)*x(5)-x(6)*x(3));
sys=(Te-Tm-Rc*x(7))/J; |
|