声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1155|回复: 1

[电力电机类] s函数的问题

[复制链接]
发表于 2008-3-28 11:48 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
在仿真过程中,出现下边的错误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 [sys,x0,str,ts] = plused(t,x,u,flag)
switch flag,
   case 0,
    [sys,x0,str,ts]=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 [sys,x0,str,ts]=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  = [0 0];

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=[1,0,0,1,0,0]
elseif(theta>=pi/3&&theta<2*pi/3)
       sys=[1,0,0,0,0,1]
elseif(theta>=2*pi/3&&theta<pi)
      sys=[0,0,1,0,0,1]
elseif(theta>=pi&&theta<4*pi/3)
       sys=[0,1,1,0,0,0]
elseif(theta>=4*pi/3&&theta<5*pi/3)
       sys=[0,1,0,0,1,0]
elseif(theta>=5*pi/3&&theta<=2*pi)
       sys=[0,0,0,1,1,0]
end

请高手指教

untitled2.mdl

62.06 KB, 下载次数: 8

回复
分享到:

使用道具 举报

发表于 2008-3-30 21:17 | 显示全部楼层
将ts  = [0 0];改为ts  = [-1 0];试试。
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-5-21 18:59 , Processed in 0.062553 second(s), 21 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表