求MATLAB大神帮忙看一看下面的程序,哪里有错误
function[sys,x0,str,ts]=chap1_3plant(t,x,u,flag)switchflag,%Initializationcase0,[sys,...
function [sys,x0,str,ts]=chap1_3plant(t,x,u,flag)
switch flag,
%Initialization
case 0,
[sys,x0,str,ts]=mdlInitializeSizes;
case 1,
sys=mdlDerivatives(t,x,u);
%Outputs
case 3,
sys=mdlOutputs(t,x,u);
%Unhandled flags
case {2,4,9}
sys=[];
%Unexpected flags
otherwise
error(['Unhandled flag=',num2str(flag)]);
end
function[sys,x0,str,ts]=mdlInitializeSizes
sizes=simsizes;
sizes.NumContStates=2;
sizes.NumDiscStates=0;
sizes.NumOutputs=1;
sizes.NumInputs=1;
sizes.DirFeedthrough=0;
sizes.NumSampleTimes=0;
sys=simsizes(sizes);
x0=[0,0];
str=[];
ts=[];
function sys=mdlDerivatives(t,x,u)
sys(1)=x(2);
%sys(2)=-(25+5*sin(t))*x(2)+(133+10*sin(t))*u;
sys(2)=-(25+10*rands(1))*x(2)+(133+30*rands(1))*u;
function sys=mdlOutputs(t,x,u)
sys(1)=x(1);
运行时总说有错误
错误描述是这样的
>> chap1_3plant(t, x, u, flag)
Undefined function or variable 't'.
检查不出来哪里错了,求大神指教 展开
switch flag,
%Initialization
case 0,
[sys,x0,str,ts]=mdlInitializeSizes;
case 1,
sys=mdlDerivatives(t,x,u);
%Outputs
case 3,
sys=mdlOutputs(t,x,u);
%Unhandled flags
case {2,4,9}
sys=[];
%Unexpected flags
otherwise
error(['Unhandled flag=',num2str(flag)]);
end
function[sys,x0,str,ts]=mdlInitializeSizes
sizes=simsizes;
sizes.NumContStates=2;
sizes.NumDiscStates=0;
sizes.NumOutputs=1;
sizes.NumInputs=1;
sizes.DirFeedthrough=0;
sizes.NumSampleTimes=0;
sys=simsizes(sizes);
x0=[0,0];
str=[];
ts=[];
function sys=mdlDerivatives(t,x,u)
sys(1)=x(2);
%sys(2)=-(25+5*sin(t))*x(2)+(133+10*sin(t))*u;
sys(2)=-(25+10*rands(1))*x(2)+(133+30*rands(1))*u;
function sys=mdlOutputs(t,x,u)
sys(1)=x(1);
运行时总说有错误
错误描述是这样的
>> chap1_3plant(t, x, u, flag)
Undefined function or variable 't'.
检查不出来哪里错了,求大神指教 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询