|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
用s函数编写异步电机模型,设置x(0)=[],提示应该设置为维度为5的向量,设置为0,0,0,0,0,提示为flag=1 call应该为维度为5的正向量。后来把x(0)=[1e-9,1e-9,1e-9,1e-9,1e-9],就可以仿了。原程序如下:
function [sys,x0,str,ts] = DFIG(t,x,u,flag)
DFIG_parameter;
switch flag,
case 0,
[sys,x0,str,ts] = mdlInitializeSizes;
case 1,
sys=mdlDerivatives(t,x,u,Rs,Rr,Ls,Lr,Lm,w1,np,J);
case 3,
sys=mdlOutputs(t,x,u,Lm,np);
case {2,4,9}
sys=[];
otherwise
DAStudio.error('Simulink:blocks:unhandledFlag', num2str(flag));
end
function [sys,x0,str,ts] = mdlInitializeSizes
sizes = simsizes;
sizes.NumContStates = 5;
sizes.NumDiscStates = 0;
sizes.NumOutputs = 6;
sizes.NumInputs = 5;
sizes.DirFeedthrough = 1;
sizes.NumSampleTimes = 1;
sys = simsizes(sizes);
x0 = [1e-9;1e-9;1e-9;1e-9;1e-9];
str = [];
ts = [0 0];
function sys = mdlDerivatives(t,x,u,Rs,Rr,Ls,Lr,Lm,w1,np,J)
A=1/(Rr*Ls-Lm*Lm)*[-Rs*Lr,w1*(Lr*Ls-Lm*Lm)-x(5)*Lm*Lm,Rr*Lm,x(5)*Lr*Lm,0;
w1*(Lm*Lm-Lr*Ls)-x(5)*Lm*Lm,-Rs*Lr,-x(5)*Lr*Lm,Rr*Lm,0;
Rs*Lm,-x(5)*Ls*Lm,-Rr*Ls,w1*(Lr*Ls-Lm*Lm)-x(5)*Lr*Ls,0;
x(5)*Ls*Lm,Rs*Lm,x(5)*Lr*Ls+w1*(Lm*Lm-Lr*Ls),-Rr*Ls,0;
-1.5*np*np*Lm*x(4)*(Ls*Lr-Lm*Lm)/J,1.5*np*np*Lm*x(3)*(Ls*Lr-Lm*Lm)/J,0,0,0];
B=1/(Rr*Ls-Lm*Lm)*[Lr,0,-Lm,0,0;0,Lr,0,-Lm,0;-Lm,0,Ls,0,0;0,-Lm,0,Ls,0;0,0,0,0,-np*(Ls*Lr-Lm*Lm)/J];
x=[x(1);x(2);x(3);x(4);x(5)];
u=[u(1);u(2);u(3);u(4);u(5)];
dx=A*x+B*u;
sys = dx;
function sys = mdlOutputs(t,x,u,Lm,np)
Te=1.5*np*Lm*(x(2)*x(3)-x(1)*x(4));
sys = [x;Te];
各位高手,这是什么原因? |
|