找回密码
 注册
Simdroid-非首页
查看: 66|回复: 0

[控制和视觉] (求助)s函数没有任何输出

[复制链接]
发表于 2012-3-21 11:00:48 | 显示全部楼层 |阅读模式 来自 新加坡
我是做机械电子控制的。现在想在控制框图中编写s函数。其中在S函数中调用了其他的函数。
控制流程图如下:

我编写了以下s函数:
function [sys,x0,str,ts]=inversePImodel(t,x,u,flag)

switch flag
    case 0                %initialize the conditions
        [sys,x0,str,ts]=mdlInitializeSizes;
    case 1                %compute the derivatives of continuous state
        sys=mdlDerivatives(t,x,u);
    case 2                %update the state
        sys=mdlUpdate(t,x,u);
    case 3                %compute the output
        sys=mdlOutput(t,x,u);
    case 4                %get the next sampling point
        sys=mdlGetTimeOfNextVarHit(t,x,u);
    case 9                %complete computation
        sys=mdlTerminate(t,x,u);
    otherwise             %false input
        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=1;
sizes.DirFeedthrough=1;
sizes.NumSampleTimes=1;
sys=simsizes(sizes);

x0=[];
str=[];
ts=[1 0];

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

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

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function sys=mdlOutput(t,x,u)
%F=[1 2 3 4;5 6 7 8;9 10 11 12]';
r=[0.0299 0.0253 0.0145 1.9702 1.8274 0.0050];
alpha=[2.2062 0.8445 0.7982 0.0244 0 0.7075];
sys=[alpha(1)*stopoperator(r(1),u)+alpha(2)*stopoperator(r(2),u)+alpha(3)*stopoperator(r(3),u)+alpha(4)*stopoperator(r(4),u)+alpha(5)*stopoperator(r(5),u)+alpha(6)*stopoperator(r(6),u)];

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function sys=mdlGetTimeOfNextVarHit(t,x,u)
sampleTime=[];

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function sys=mdlTerminate(t,x,u)%FUNCTION SYS=MDLtERMINATE(T,X,U)
sys=[];


在这个s函数中,我调用了别的函数operator(r,x).
另一个s函数的情况也与这个类似。
但是运行的时候出现问题了:从s函数模块中没有任何输出信号。

求助......
谢谢

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|小黑屋|联系我们|仿真互动网 ( 京ICP备15048925号-7 )

GMT+8, 2024-4-29 00:56 , Processed in 0.025915 second(s), 11 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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