在Scilab v5.5.2中,此代码执行时没有问题。 在Scilab v6.0.0或更高版本中,我收到以下错误,
lsode--在t(= r1),mxstep(= i1)步骤
到达之前必要的
其中i1是:500
其中r1为:0.1202764106130D-05
在此调用上完成的工作过多(可能是错误的jacobian类型)。
在函数csim的第159行(C:\ Program Files \ scilab-6.0.1 \ modules \ cacsd \ macros \ csim.sci第170行)
在执行文件C的第39行:\ Users \ wensrl \ Documents \ SciLab \ Control \ optTest2.sce
ode:lsode退出,状态为-1。
这是代码,
clear
clc
t = linspace(1, 520, 5200)
for i = 1:5200
if (i > 15) then
if (i < (5200 / 2)) then
u(i) = 1;
else
u(i) = 0;
end
else
u(i) = 0;
end
end
P = syslin('c', 0.72, 1 + 11 * %s);
n = 4 // order of the delay function
delay = 1 / (( 1 + ((%s * 3) / n)) ^n); // make into a function
Pd = P * delay;
x0=[7.1373457 6.6467066 1.0393701 0.125];
kc = x0(1);
ki = x0(2);
kd = x0(3);
alpha = x0(4);
// stdDeltaV PID formula
pidFormula = kc * (1 + (1/(ki * %s)) + ...
((kd * %s)/(alpha * kd * %s + 1)));
C = syslin('c', pidFormula);
oL = Pd * C;
cL = oL /. 1;
[y] = csim(u', t, cL)
答案 0 :(得分:0)
对我而言,它与scilab-5.5.2和scilab-6.0.1类似地工作。 但请注意,ode求解器应该是连续系统。这里您的输入是不连续的,因此求解器难以集成它,结果可能是错误的。 实际上,您应该为每个连续部分进行3次成功整合
[y1,x1]=csim(u(1:15)',t(1:15),cL);
[y2,x2]=csim(u(15:2599)',t(15:2599)-t(15),cL,x1(:,$));
[y3,x3]=csim(u(2599:$)',t(2599:$)-t(2599),cL,x2(:,$));
clf(),plot([t(1:15) t(15:2599) t(2599:$)],[y1 y2 y3])