- 积分
- 643
- 回帖
- 0
- 西莫币
-
- 贡献
-
- 威望
-
- 存款
-
- 阅读权限
- 25
- 最后登录
- 1970-1-1
签到天数: 3 天 连续签到: 2 天 [LV.2]偶尔看看I
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
X'=A*X+B*U
y=C*x+D*U;用的是连续状态,编写s函数时因为矩阵A中有未知数w,具体的程序如下:
function [sys,x0,str,ts,simStateCompliance] = quanjie(t,x,u,flag)
Rs=1.405;
Ls=0.178039;
Rr=1.395;
Lr=0.178039;
Lm=0.1722;
Rsr=Rs+(Lm/Lr)^2*Rr;
Ls1=Ls-Lm^2/Lr;
Tsr=Ls1/Rsr;
Tr=Lr/Rr;
switch flag,
case 0,
[sys,x0,str,ts,simStateCompliance]=mdlInitializeSizes;
case 1,
sys=mdlDerivatives(t,x,u);
case 3,
sys=mdlOutputs(t,x,u);
case {2,4,9}
sys = [];
otherwise
DAStudio.error('Simulink:blocks:unhandledFlag', num2str(flag));
end
function [sys,x0,str,ts,simStateCompliance]=mdlInitializeSizes
sizes = simsizes;
sizes.NumContStates = 4;
sizes.NumDiscStates = 0;
sizes.NumOutputs = 4;
sizes.NumInputs = 2;
sizes.DirFeedthrough = 1;
sizes.NumSampleTimes = 1; % at least one sample time is needed
sys = simsizes(sizes);
x0 = [0 0 0 0]';
str = [];
ts = [0 0];
simStateCompliance = 'UnknownSimState';
function sys=mdlDerivatives(t,x,u)
A=[-1/Tsr 0 Lm/(Ls1*Lr*Tr) Lm*wr/(Ls1*Lr)
0 -1/Tsr -Lm*wr/(Ls1*Lr) Lm/(Ls1*Lr*Tr)
Lm/Tr 0 -1/Tr -wr;
0 Lm/Tr wr -1/Tr ];
B=[1/Ls1 1/Ls1 0 0]';
sys = A*x+B*u;
function sys=mdlOutputs(t,x,u)
C=[1 0 0 0
0 1 0 0
0 0 0 0
0 0 0 0];
sys = C*x;
wr是要通过观测器出来的4个量计算的,怎么把wr值给入到矩阵中进行运算啊?我理解的s函数输入参数外,其他输入为状态变量的输入。请高人指教,感激! |
|