bandit05 发表于 2006-11-28 16:09

求助:s-function builder参数设置

我最近在编一个s函数,源代码如下:
function =panduan(t,x,u0,flag)
%   S-file example 1
%   This is an S-file subsystem with no states. It performs
%   the algebraic function y = u(1) + u(2)^2. There are two
%   inputs and one output.
%
%   Based on sfuntmpl.m, supplied with SIMULINK
%   Copyright (c) 1990-96 by The MathWorks, Inc.
%
switch flag
case 0          % Initialization
    =mdlInitializeSizes();
case 1          % Compute derivatives of continuous states
    y0=mdlDerivatives(t,x,u0);
case 2
    y0=mdlUpdate(t,x,u0);
case 3
    y0=mdlOutputs(t,x,u0);% Compute output vector
%case 4               % Compute time of next sample
    %sys=mdlGetTimeOfNextVarHit(t,x,u);
%case 9                  % Finished. Do any needed
    %sys=mdlTerminate(t,x,u);
%otherwise               % Invalid input
   % error(['Unhandled flag = ',num2str(flag)]);
end;

%***************************************************************
%*                  mdlInitializeSizes                     *
%***************************************************************
function =mdlInitializeSizes()
% Return the sizes of the system vectors, initial conditions, and
% the sample times and offets.
sizes = simsizes;   % Create the sizes structure
sizes.NumContStates= 0;
sizes.NumDiscStates= 3;
sizes.NumOutputs   = 1;
sizes.NumInputs      = 1;
sizes.DirFeedthrough = 1;
sizes.NumSampleTimes = 1;   % at least one sample time is needed
y0 = simsizes(sizes);      % load sys with the sizes structure
x0= ; % Specify initial conditions for all states
str = [];    % str is always an empty matrix
ts= ; %initialize the array of sample times


%***************************************************************
%*                  mdlDerivatives                           *
%***************************************************************
function y0=mdlDerivatives(t,x,u0)
% Compute derivatives of continuous states
sys = [];   % Empty since this S-file has no continuous states

%***************************************************************
%*                  mdlUpdate                              *
%***************************************************************
function y0=mdlUpdate(t,x,u0)
% Compute update for discrete states. If necessary, check for
% sample time hits.
if u0>=2
   x(1)=x(1)+1;
   x(2)=x(1);
   x(3)=1
   y0=;
    else if x(2)>1&&u0<2
      x(3)=1
      y0=;
      else
            x(3)=0
         y0=;
      end
end


%***************************************************************
%*                  mdlOutputs                               *
%*Output compensation torque to nonlinear friction         *
%***************************************************************
function y0=mdlOutputs(t,x,u0)
y0=x(3);
在s-function builder里面编译之后
出现如下问题:
kaiguan0.obj : error LNK2001: unresolved external symbol _panduan_Outputs_wrapper
kaiguan0.obj : error LNK2001: unresolved external symbol _panduan_Update_wrapper
kaiguan0.dll : fatal error LNK1120: 2 unresolved externals
NMAKE : fatal error U1077: 'link' : return code '0x460'
Stop.
希望哪位老师能给我一点指点,不胜感激!!!!!!!!!

bandit05 发表于 2006-11-29 09:50

怎么没有人给我一个回复呢?
页: [1]
查看完整版本: 求助:s-function builder参数设置