1.问题描述
复现论文Adaptive nonsingular fast terminal sliding-mode control for the tracking problem of uncertain dynamical systems(https://doi.org/10.1016/j.isatra.2018.04.007)
在自适应律处出现问题,描述如下:
“An error occurred while running the simulation and the simulation was terminated Caused by: Error in 'untitled1/S-Function3' while executing MATLAB S-function 'A_Adapt', flag = 1 (derivatives), at time 0.0. 无法执行赋值,因为左侧的索引与右侧的大小不兼容”
2.问题分析
分析后发现是文章的自适应律为2×1数组形式,编程误看为1×1实函数。
3.问题解决
将自适应律S函数部分:
sys(1)=b0;
sys(2)=b1;
sys(3)=b2;
function sys=mdlOutputs(t,x,u)
sys(1)=x(1);
sys(2)=x(2);
sys(3)=x(3);
修改为
sys(1:2)=b0;
sys(3:4)=b1;
sys(5:6)=b2;
function sys=mdlOutputs(t,x,u)
sys(1)=x(1);
sys(2)=x(2);
sys(3)=x(3);
sys(4)=x(4);
sys(5)=x(5);
sys(6)=x(6);
问题解决!