紧急求助关于s函数的问题!!
我的这个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 = spacemodel(t,x,u,flag)
switch flag,
case 0,
=mdlInitializeSizes;
case 3,
sys=mdlOutputs(t,x,u);
case {2,4,9}
sys=[];
otherwise
error(['Unhandled flag = ',num2str(flag)]);
end
function =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; sizes.NumSampleTimes = 0
采样时间至少是1吧 楼上的说的对,采样时间个数至少是一个。然后在ts【】中写入你的采样时间和滞后时间。 sizes.NumSampleTimes = 0; % At least one sample time is needed这里的英文就已经说明了
本版面有个S函数的精华帖子后面有S函数的详细例程连接,希望对楼主有用。 我改了那个采样时间问题依旧啊!!!希望高手们帮帮忙啊 1:关于S函数请参考本版面很多S函数的帖子,希望能够尽力自己解决
2: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).
这个错误不是S函数造成的啊?明明就是模块上的错误,但不是积分器的错误,只能说明是数据计算时候错误,这样的错误没有定论的,肯定也不是步长错误,只能看下你的系统模型了。
页:
[1]