[未答复] 神经网络自适应控制程序请教!

[复制链接]
GoMonMon 发表于 6 天前
代码如下:
function[sys,x0,str,ts] = ctrl(t,x,u,flag)
switch flag
    case 0
        [sys,x0,str,ts] = mdlInitializeSizes;
    case 1
        sys = mdlDerivatives(t,x,u);
    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  = 1;
sizes.NumDiscStates  = 0;
sizes.NumOutputs     = 5;
sizes.NumInputs      = 6;
sizes.DirFeedthrough = 1;
sizes.NumSampleTimes = 1;
sys = simsizes(sizes);
x0 = 0.5;
str = [];
ts = [-1 0];

function sys = mdlDerivatives(t,x,u)
yr = 0.2 * sin(t); dyr = 0.2 * cos(t);
omega2 = u(2);
alfa2 = u(3);
x1 = u(4);
x2 = u(5);
y = u(6);
kappa2 = 0.001;
domega2 = (1/kappa2) * (alfa2 - omega2);
z1 = y - yr;
z2 = x2 - omega2;
theta = x(1);
Z1 = [x1 z1 theta dyr]';
Z2 = [x1 x2 z2 domega2 theta]';
s1 = zeros(1,9);
s2 = zeros(1,9);
for j = 1:9
    eta1(j) = 2;
    v1(:,j) = (j - 5) *  [1 1 1 1]';
    s1(j) = exp(-((norm(Z1 - v1(:,j))^2))/(eta1(j)^2));
    eta2(j) = 2;
    v2(:,j) = 0.5 * (j - 5) *  [1 1 1 1 1]';
    s2(j) = exp(-((norm(Z2 - v2(j)))^2)/(eta2(j)^2));
end
S1Z1 = s1';
S2Z2 = s2';
kz1 = 0.01;
a1 = 2; a2 = 2;
eta = 100; sigma = 0.05;
g1_bar = 2; g2_bar = 1;
sys(1) = (((g1_bar * z1^2)/(2 * a1^2 * (kz1^2 - z1^2))) * (S1Z1'*S1Z1) + ((g2_bar * z2^2)/(2 * a2^2 * (kz1^2 - z1^2))) * (S2Z2'*S2Z2) - eta * sigma) * theta;

function sys = mdlOutputs(t,x,u)
theta = x(1);
k2 = 2;
h0 = 0.9;
omega2 = u(2);
x1 = u(4);
x2 = u(5);
y = u(6);
z2 = x2 - omega2;
a2 = 2;
yr = 0.2 * sin(t);
z1 = y - yr;
kz1 = 0.01;
Z2 = [x1 x2 z2 0 theta]';
for j = 1:9
    eta2(j) = 2;
    v2(:,j) = 0.5 * (j - 5) *  [1 1 1 1 1]';
    s2(j) = exp(-((norm(Z2 - v2(j)))^2)/(eta2(j)^2));
end
S2Z2 = s2';
vt= -(1/h0) * (k2 * z2 + (z2/(2 * a2^2 * (kz1^2 - z1^2))) * theta * (S2Z2'*S2Z2));
um = 15;
if (abs(vt)>=um)
    ut = sign(vt) * um;
else
    ut = vt;
end
sys(1) = ut;
sys(2) = x(1);
sys(3) = z2;
sys(4) = z1;
sys(5) = vt;

报错问题如图1所示.
搭建的simulink如图2. 是一个神经网络自适应控制,反步法的动态面控制。请问大佬们错误出在哪呢,以及大佬们有没有类似地(神经网络动态面自适应控制)设计的相关的程序,可不可以发给我一份呢,控制理论小白觉着太难了(呜呜呜)。谢谢谢!

图2

图2

图1

图1
您需要登录后才可以回帖 登录 | 注册

本版积分规则

相关帖子
相关文章
热门教程
站长推荐
快速回复 返回顶部 返回列表