马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
我的这个s函数老是提示如下错误请各位帮忙看下啊。错误信息如下:
Trouble solving algebraic loop containing 'backstepping_1/Vo1/source/Switches2/Model1/Tail/Integrator' at time 6.553660664072742e-006. Stopping simulation. There may be a singularity in the solution. If the model is correct, try reducing the step size (either by reducing the fixed step size or by tightening the error tolerances).
源程序如下:
function [sys,x0,str,ts] = spacemodel(t,x,u,flag)
switch flag,
case 0,
[sys,x0,str,ts]=mdlInitializeSizes;
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 = 0;
sizes.NumDiscStates = 0;
sizes.NumOutputs = 1;
sizes.NumInputs = 2;
sizes.DirFeedthrough = 1;
sizes.NumSampleTimes = 0; % At least one sample time is needed
sys = simsizes(sizes);
x0 = [];
str = [];
ts = [];
function sys=mdlOutputs(t,x,u)
E=20;L=10^(-6)*92;C=10^(-6)*200;R=8;Rl=10^(-3)*74;Rc=70*10^(-3);Rd=30*10^(-3);
Rs=44*10^(-3);c0=120;c1=60000;k1=50000;k2=2000;c2=50000;
q1=-1/((R+Rc)*C);
q2=R/((R+Rc)*C);
q3=-R/((R+Rc)*L);
q4=-R*Rc/((R+Rc)*L)-Rl/L-Rd/L;
q5=E/L;
Vd=8;
tao=u(1)*t-Vd*t;
dtao=u(1)-Vd;
a0=-c0*tao+Vd;
da0=-c0*(u(1)-Vd);
a1=1/q2*(-c1*(u(1)-a0)-tao-q1*u(1)+da0)
rou=u(2)-a1;
dda0=-c0*(q1*u(1)+q2*u(2));
da1=1/q2*((c1*da0-(u(1)-Vd)+dda0)+(-c1-q1)*(q1*u(1)+q2*u(2)));
%ut=1/q5*(-c2*(u(2)-a1)-q2*(u(1)-a0)-q3*u(1)-q4*u(2)+da1);
ut=1/q5*(-q2*(u(1)-a0)-q3*u(1)-q4*u(2)+da1-k1*rou-k2*sign(rou));
sys(1)=ut; |