声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1707|回复: 1

求助:s-function builder参数设置

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

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

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

x
我最近在编一个s函数,源代码如下:
function [y0,x0,str,ts] =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
    [y0,x0,str,ts]=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 [y0,x0,str,ts]=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  = [1;1;0]; % Specify initial conditions for all states
str = [];    % str is always an empty matrix
ts  = [0 0]; %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=[x(1);x(2);x(3)];
    else if x(2)>1&&u0<2
        x(3)=1
        y0=[x(1);x(2);x(3)];
        else
            x(3)=0
           y0=[x(1);x(2);x(3)];
        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.
希望哪位老师能给我一点指点,不胜感激!!!!!!!!!
回复
分享到:

使用道具 举报

 楼主| 发表于 2006-11-29 09:50 | 显示全部楼层
怎么没有人给我一个回复呢?
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

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

GMT+8, 2024-9-21 15:32 , Processed in 0.054308 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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