xiuxiu 发表于 2008-3-28 11:48

s函数的问题

在仿真过程中,出现下边的错误Error in block 'untitled2/POSITION DETECT/S-Function' while executing M-File S-function block 'pulsed', flag = 3 (output), at time 0.001079639262278552. MATLAB error message:
One or more output arguments not assigned during call to 'pulsed (mdlOutputs)'。其中s函数如下:
function = plused(t,x,u,flag)
switch flag,
   case 0,
    =mdlInitializeSizes;
case 1,
    sys=[];
case 2,
    sys=[];
case 3,
    sys=mdlOutputs(t,x,u);
   case 4,
    sys=[];
case 9,
    sys=[];
otherwise
    error(['Unhandled flag = ',num2str(flag)]);
end

function =mdlInitializeSizes
sizes = simsizes;
sizes.NumContStates= 0;
sizes.NumDiscStates= 0;
sizes.NumOutputs   = 6;
sizes.NumInputs      = 1;
sizes.DirFeedthrough = 1;
sizes.NumSampleTimes = 1;   % at least one sample time is needed
sys = simsizes(sizes);
x0= [];
str = [];
ts= ;

function sys=mdlDerivatives(t,x,u)
sys = [];

function sys=mdlUpdate(t,x,u)
sys = [];

function sys=mdlOutputs(t,x,u)
theta=u(1);
if(theta>=0&&theta<pi/3)
       sys=
elseif(theta>=pi/3&&theta<2*pi/3)
       sys=
elseif(theta>=2*pi/3&&theta<pi)
      sys=
elseif(theta>=pi&&theta<4*pi/3)
       sys=
elseif(theta>=4*pi/3&&theta<5*pi/3)
       sys=
elseif(theta>=5*pi/3&&theta<=2*pi)
       sys=
end

请高手指教

wdzdlt 发表于 2008-3-30 21:17

将ts= ;改为ts= [-1 0];试试。
页: [1]
查看完整版本: s函数的问题