|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
:@Q 为什么老是又错误啊?
哪位大侠行侠仗义啊
帮帮忙呀
急用呀!
多谢多谢啊!
输入是Us,Is,n0,输出是磁链Ψα,Ψβ与转矩Tf
%异步机模型的S-函数
function [sys,x0,str,ts] = ybj(t,x,u,flag)
switch flag,
%Initialization
case 0,
[sys,x0,str,ts]=mdlInitializeSizes;
%Derivatives
case 1,
sys=mdlDerivatives(t,x,u);
%Output
case 3,
sys=mdlOutputs(t,x,u);
%Terminate
case {2,4,9}
sys=[];
otherwise
error(['Unhandled flag = ',num2str(flag)]);
end
%end sfundsc2
%mdlInitializeSizes
function [sys,x0,str,ts]=mdlInitializeSizes
sizes = simsizes;
sizes.NumContStates = 8;
sizes.NumDiscStates = 0;
sizes.NumOutputs = 5;
sizes.NumInputs = 7;
sizes.DirFeedthrough = 0;
sizes.NumSampleTimes = 1;
sys = simsizes(sizes);
x0 = zeros(8,1);
str = [];
ts = [0 0];%Sample period of 0.1 seconds(10Hz)
%end mdlInitializeSizes
%function sys=mdlDerivatives(t,x,u,R1,R2,LA,M1,M2,MAa,Rs,Ls,Lr,J,Rw)
function sys=mdlDerivatives(t,x,u)
R1=0.252;
R2=0.332;
p0=2;
LA=0.0816;
M1=0.04;
M2=M1;
MAa=0.08;
Rs=diag([R1*ones(1,3),R2*ones(1,3)]);
Ls=[LA -M1 -M1;-M1 LA -M1;-M1 -M1 LA];
Lr=Ls;
J=0.075;
Rw=0.0375;
Msr=MAa*[cos(x(8)) cos(x(8)+2*pi/3) cos(x(8)-2*pi/3);cos(x(8)-2*pi/3) cos(x(8)) cos(x(8)+2*pi/3);cos(x(8)+2*pi/3) cos(x(8)-2*pi/3) cos(x(8))];
Mrs=Msr';
L=[Ls Msr;Mrs Lr]
K1=inv(L);
%K2=dMrs/dSt
K2=-MAa*[sin(x(8)) sin(x(8)+2*pi/3) sin(x(8)-2*pi/3);sin(x(8)-2*pi/3) sin(x(8)) sin(x(8)+2*pi/3);sin(x(8)+2*pi/3) sin(x(8)-2*pi/3) sin(x(8))];
%K3=dMrs/dt
K3=p0*x(7)*K2;
%K4=dL/dSt
K4=[zeros(3,3),K2;K2',zeros(3,3)];
%K5=dL/dt
K5=[zeros(3,3),K3;K3',zeros(3,3)];
A=[-K1*(Rs+K5),zeros(6,1),zeros(6,1);p0*x(1:6)'*K4/(2*J),-Rw/J,0;zeros(1,6),p0,0];
B=[K1,zeros(6,1);zeros(1,6),-1/J;zeros(1,6),0];
sys=A*x+B*u;
function sys=mdlOutputs(t,x,u)
MAa=0.08;
p0=2;
K2=-MAa*[sin(x(8)) sin(x(8)+2*pi/3) sin(x(8)-2*pi/3);sin(x(8)-2*pi/3) sin(x(8)) sin(x(8)+2*pi/3);sin(x(8)+2*pi/3) sin(x(8)-2*pi/3) sin(x(8))];
K4=[zeros(3,3),K2;K2',zeros(3,3)];
sys(1:3)=x(1:3);
sys(4)=30*x(7)/pi;
sys(5)=p0*x(1:6)'*K4*x(1:6)/2;
%end mdloutputs |
|