毕业设计的一个MATLAB的仿真问题,求解答
function[sys,x0,str,ts]=spacemodel(t,x,u,flag)switchflag,case0,[sys,x0,str,ts]=mdlIni...
function [sys,x0,str,ts] = spacemodel(t,x,u,flag)
switch flag,
case 0,
[sys,x0,str,ts]=mdlInitializeSizes;
case 3,
sys=mdlOutputs(t,x,u);
case {1,2,4,9}
sys=[];
otherwise
error(['Unhandled flag = ',num2str(flag)]);
end
function [sys,x0,str,ts]=mdlInitializeSizes
sizes = simsizes;
sizes.NumContStates = 0;
sizes.NumDiscStates = 0;
sizes.NumOutputs = 1;
sizes.NumInputs = 3;
sizes.DirFeedthrough = 1;
sizes.NumSampleTimes = 0;
sys = simsizes(sizes);
x0 = [];
str = [];
ts = [];
function sys=mdlOutputs(t,x,u)
thd=0.1*sin(t);
dthd=0.1*cos(t);
ddthd=-0.1*sin(t);
x1=u(2);
x2=u(3);
e=thd-x1;
de=dthd-x2;
c=15;
s=c*e+de;
g=9.8;mc=1.0;m=0.1;l=0.5;
T=l*(4/3-m*(cos(x1))^2/(mc+m));
fx=g*sin(x1)-m*l*x2^2*cos(x1)*sin(x1)/(mc+m);
fx=fx/T;
gx=cos(x1)/(mc+m);
gx=gx/T;
xite=0.20;
M=2;
if M==1
ut=1/gx*(-fx+ddthd+c*de+xite*sign(s));
elseif M==2 %Saturated function
delta=0.05;
kk=1/delta;
if abs(s)>delta
sats=sign(s);
else
sats=kk*s;
end
ut=1/gx*(-fx+ddthd+c*de+xite*sats);
end
sys(1)=ut;
请问为什么执行后会出现Error using chap13_6ctrl (line 2)
Not enough input arguments.求大神指点,帮我改好了,财富值好说 展开
switch flag,
case 0,
[sys,x0,str,ts]=mdlInitializeSizes;
case 3,
sys=mdlOutputs(t,x,u);
case {1,2,4,9}
sys=[];
otherwise
error(['Unhandled flag = ',num2str(flag)]);
end
function [sys,x0,str,ts]=mdlInitializeSizes
sizes = simsizes;
sizes.NumContStates = 0;
sizes.NumDiscStates = 0;
sizes.NumOutputs = 1;
sizes.NumInputs = 3;
sizes.DirFeedthrough = 1;
sizes.NumSampleTimes = 0;
sys = simsizes(sizes);
x0 = [];
str = [];
ts = [];
function sys=mdlOutputs(t,x,u)
thd=0.1*sin(t);
dthd=0.1*cos(t);
ddthd=-0.1*sin(t);
x1=u(2);
x2=u(3);
e=thd-x1;
de=dthd-x2;
c=15;
s=c*e+de;
g=9.8;mc=1.0;m=0.1;l=0.5;
T=l*(4/3-m*(cos(x1))^2/(mc+m));
fx=g*sin(x1)-m*l*x2^2*cos(x1)*sin(x1)/(mc+m);
fx=fx/T;
gx=cos(x1)/(mc+m);
gx=gx/T;
xite=0.20;
M=2;
if M==1
ut=1/gx*(-fx+ddthd+c*de+xite*sign(s));
elseif M==2 %Saturated function
delta=0.05;
kk=1/delta;
if abs(s)>delta
sats=sign(s);
else
sats=kk*s;
end
ut=1/gx*(-fx+ddthd+c*de+xite*sats);
end
sys(1)=ut;
请问为什么执行后会出现Error using chap13_6ctrl (line 2)
Not enough input arguments.求大神指点,帮我改好了,财富值好说 展开
上海华然企业咨询
2024-10-28 广告
2024-10-28 广告
在上海华然企业咨询有限公司,我们深知模型训练数据集对于AI项目成功至关重要。我们的数据集构建遵循高标准,确保数据质量、多样性与代表性。这些数据集涵盖广泛行业案例,如市场趋势分析、客户行为预测等,通过精心筛选与标注,为机器学习模型提供丰富的学...
点击进入详情页
本回答由上海华然企业咨询提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询