首页新闻找找看学习计划

S函数运行报错,返回的状态导数必须是长度为3的实数向量 这类问题怎么解决?

0
悬赏园豆:20 [待解决问题]

请求大佬 指点下!错误如下图所示

报错的这部分的代码如下:
function [sys,x0,str,ts]=s_function2(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 = 3;
sizes.NumDiscStates = 0;
sizes.NumOutputs = 2;
sizes.NumInputs = 2;
sizes.DirFeedthrough = 0;
sizes.NumSampleTimes = 0;
sys=simsizes(sizes);
x0=[0.03;0.01;2];
str=[];
ts=[];

function sys=mdlDerivatives(t,x,u)
ap=9.425;be=1700000000;cd=0.65;w=0.001;
vt=280;ps=4000000;p=9000;ctp=0.00001;
ks=0.6;mt=60;fc=270;fm=500;vs=0.05;
ut=u(1);
f=u(2);
sys(1)=x(2);
sys(2)=1/mt(-10000x(2)+apx(3)-f);
sys(3)=4
be/vt(cdkswsqrt((ps-sign(x(1))x(3))/p)ut-apx(2)-ctpx(3));

function sys=mdlOutputs(t,x,u)
sys(1)=x(1);
sys(2)=x(2);

GRIT_风的主页 GRIT_风 | 初学一级 | 园豆:182
提问于:2019-08-28 21:01
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册