faith824206 发表于 2006-11-13 21:44

仿真时这个错误总解决不了,请帮忙

仿真时总出现如下报错:
Error executing build command: Error using ==> make_rtw
Error using ==> tlc_c (InvokeTLC)
Error: File: C:\MATLAB6p5\rtw\c\tlc\lib\utillib.tlc Line: 173 Column: 8
%exit directive:Real-Time Workshop Fatal in block: "fangzhen/S-Function2", block type "S-Function": MFile S-functions without a corresponding TLC file are not supported. You can inline your S-function (Sa) by creating a TLC file for it. You can also remap your S-function to C by creating a corresponding C Mex source file and a Sa.tlc file in the same directory as the MFile S-function which contains (on the first line):
%% CallAsCMexLevel1
or
%% CallAsCMexLevel2

不论怎么改变仿真模块都报如上错误,s函数应该没有问题,请问这是怎么回事?

[ 本帖最后由 faith824206 于 2006-11-14 09:55 编辑 ]

swqsxm 发表于 2006-11-14 09:55

你用的是实时仿真吧?s函数是用C语言编的吗?

faith824206 发表于 2006-11-14 09:58

原帖由 swqsxm 于 2006-11-14 09:55 发表
你用的是实时仿真吧?s函数是用C语言编的吗?


s函数调用了M文件形式的S函数模版

swqsxm 发表于 2006-11-14 10:04

实时仿真应该是只支持C语言编写的s函数。

faith824206 发表于 2006-11-15 15:51

原帖由 swqsxm 于 2006-11-14 10:04 发表
实时仿真应该是只支持C语言编写的s函数。

请问如何编译C语言S函数?怎么设置编译环境?
谢谢

swqsxm 发表于 2006-11-15 20:44

不好意思,我没具体编过s函数,我只是知道有这么回事。你可以找一本关于Simulink的书,基本上都应该有。不行的话你可以找《应用MATLAB建模与仿真》这本书看一下,里面讲了怎么编写。

faith824206 发表于 2006-11-16 09:11

一般的matlab书里都没有具体说明怎么编译C语言的S函数

我朋友仿真模型里用过S函数,他用的就是M文件编程,没出现这种问题

请问我的症结在哪里?

swqsxm 发表于 2006-11-16 18:41

他是用的实时仿真吗?如果不是实时仿真的话是没问题的。建议你去研学论坛看一下,那里有人讨论过。我在做实时仿真的时候没有用到s函数,但是我记得书上写的是只支持C语言的,我没具体操作过,也不好说。

[ 本帖最后由 swqsxm 于 2006-11-16 18:45 编辑 ]

littlesea 发表于 2006-11-17 12:04

我在使用simulink做仿真的时候也碰到了这个问题,就是在build的时候会报这个错误。但是我没有理会这个,而直接运行,结果s-function的功能完全正常。可以运行的。。呵呵~~我matlab用的也不是很多只是今天看到你的帖子,和自己以前碰到的一样,就分享一下自己的经验。。有不对的地方请指点~~

linlin820 发表于 2006-11-20 04:06

原帖由 faith824206 于 2006-11-15 15:51 发表


请问如何编译C语言S函数?怎么设置编译环境?
谢谢

mex编译

faith824206 发表于 2006-11-20 10:00

在设置编译,在命令行输入 mex-setup后有如下错误报告
>> mex-setup
    Usage:
      MEX sourcefile1 [... sourcefileN]
            

      or (to build an Ada S-function):
      MEX [-v] [-g] -ada <sfcn>.ads

    Use the -help option for more information, or consult the MATLAB API Guide.


C:\MATLAB6P5\BIN\WIN32\MEX.PL: Error: No file names given.

??? Undefined function or variable 'setup'.

这是怎么回事?

glise 发表于 2006-11-20 10:09

mex和-setup之间有一个空格

faith824206 发表于 2006-11-20 20:43

原帖由 glise 于 2006-11-20 10:09 发表
mex和-setup之间有一个空格

非常感谢,但是编译时还是不行
Installing the MATLAB Visual Studio add-in ...

Warning: Could not update D:\common\msdev98\template\MATLABWizard.awx
    from C:\MATLAB6P5\BIN\WIN32\MATLABWizard.awx
Warning: Could not update D:\common\msdev98\template\MATLABWizard.hlp
    from C:\MATLAB6P5\BIN\WIN32\MATLABWizard.hlp
Warning: Could not update D:\common\msdev98\addins\MATLABAddin.dll
    from C:\MATLAB6P5\BIN\WIN32\MATLABAddin.dll
Warning: Could not update D:\common\msdev98\bin\usertype.dat
    from C:\MATLAB6P5\BIN\WIN32\usertype.dat

Note: One or more components necessary to the operation of the MATLAB Visual
      Studio add-in could not be installed. The MATLAB Visual Studio add-in
      will not be available, but the rest of this setup operation will
      continue normally.
>> mex Sa.c

C:\MATLAB6P5\BIN\WIN32\MEX.PL: Error: Compile of 'Sa.c' failed.

??? Error using ==> mex
Unable to complete successfully
苦恼

faith824206 发表于 2006-11-20 20:49

Select a compiler:
Digital Visual Fortran version 6.0 in C:\Program Files\Microsoft Visual Studio
Lcc C version 2.4 in C:\MATLAB6P5\sys\lcc
Microsoft Visual C/C++ version 6.0 in D:

None

我只有选择2的时候才可以编译成功,请问为什么1,3不行? 我的vc装在C:\Program Files里
选1的报告:
Please verify your choices:

Compiler: Digital Visual Fortran 6.0
Location: C:\Program Files\Microsoft Visual Studio

Are these correct?(/n): y

The default options file:
"C:\Documents and Settings\whb\Application Data\MathWorks\MATLAB\R13\mexopts.bat"
is being updated from C:\MATLAB6P5\BIN\WIN32\mexopts\df60opts.bat...

Warning! The MathWorks has determined that Digital Fortran 6.0 has several
serious bugs, and highly recommends that you upgrade to the latest version
of Compaq Fortran.
选3的报告
The default options file:
"C:\Documents and Settings\whb\Application Data\MathWorks\MATLAB\R13\mexopts.bat"
is being updated from C:\MATLAB6P5\BIN\WIN32\mexopts\msvc60opts.bat...

Installing the MATLAB Visual Studio add-in ...

Warning: Could not update C:\Program Files\Microsoft Visual Studio\common\msdev98\template\MATLABWizard.awx
    from C:\MATLAB6P5\BIN\WIN32\MATLABWizard.awx
Warning: Could not update C:\Program Files\Microsoft Visual Studio\common\msdev98\template\MATLABWizard.hlp
    from C:\MATLAB6P5\BIN\WIN32\MATLABWizard.hlp
Warning: Could not update C:\Program Files\Microsoft Visual Studio\common\msdev98\addins\MATLABAddin.dll
    from C:\MATLAB6P5\BIN\WIN32\MATLABAddin.dll
Warning: Could not update C:\Program Files\Microsoft Visual Studio\common\msdev98\bin\usertype.dat
    from C:\MATLAB6P5\BIN\WIN32\usertype.dat

Note: One or more components necessary to the operation of the MATLAB Visual
      Studio add-in could not be installed. The MATLAB Visual Studio add-in
      will not be available, but the rest of this setup operation will
      continue normally.

[ 本帖最后由 faith824206 于 2006-11-20 21:51 编辑 ]

linlin820 发表于 2006-11-21 07:15

选择1时

Warning! The MathWorks has determined that Digital Fortran 6.0 has several
serious bugs, and highly recommends that you upgrade to the latest version
of Compaq Fortran.

版本太低了,建议升级Compaq Fortran 6.5或者6.6
不过你这里是c语言写的,所以要选择3
页: [1] 2
查看完整版本: 仿真时这个错误总解决不了,请帮忙