|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
shenjingyuanPID.mdl
(11.83 KB, 下载次数: 19)
本人做了一个神经元PID的s函数,但运行后老是显示错误。请高手帮帮忙,看是什么问题,应该怎么修改
s函数如下:
function [sys,x0,str,ts] = neuro(t,x,u,flag,P,I,D)
switch flag,
case 0,
[sys,x0,str,ts]=mdlInitializeSizes;
case 2,
sys=mdlUpdate(t,x,u,P,I,D);
case 3,
sys=mdlOutputs(t,x,u);
case{1,4,9}
sys=[];
otherwise
error(['Unhandled flag = ',num2str(flag)]);
end
function [sys,x0,str,ts]=mdlInitializeSizes
sizes = simsizes;
sizes.NumContStates = 0;
sizes.NumDiscStates = 3;
sizes.NumOutputs = 1;
sizes.NumInputs = 3;
sizes.DirFeedthrough = 0;
sizes.NumSampleTimes = 1;
sys = simsizes(sizes);
x0 = [0.3,0.3,0.3];
str = [];
ts = [-1 0];
function sys=mdlUpdate(t,x,u,P,I,D)
sys(1,1) = x(1)+P*u(1)*u(1);
sys(2,1) = x(2)+I*u(1)*u(2);
sys(3,1) = x(3)+D*u(1)*u(3);
function sys=mdlOutputs(t,x,u)
sys =1.1*(x(1)*u(1)+x(2)*u(2)+x(3)*u(3))/(x(1)+x(2)+x(3));
end
其显示的错误是:Output returned by S-function 'neuro' in block 'shenjingyuanPID/S-Function' during flag=3 call must be a real vector of length 1 |
|