C-Code Level 2 S-Function Name
显示 更早的评论
Hey,
I have a verry basic problem. I want to create a C-Code Level 2 S-Function using the mex command. I want to chance the name of the mex-file (mexw32) but not the name of the c-file.
Therefore I tried to change my trusty old friend timestwo.c.
#define S_FUNCTION_NAME sfun_timestwo
#define S_FUNCTION_LEVEL 2
#include "simstruc.h"
I tried to use the lcc-win32 and the MS SDK 7.1 compiler. My MatLab version beeing R2013a.
When I use
mex timestwo.c
the outcome is allways timestwo.mexw32 but not sfun_timestwo.mexw32.
Of cause I get an object name error when I try to run a simulation containing this S-Function.
"Error while obtaining sizes from MEX S-function 'timestwo' in 'timestwo_mdl/S-Function'.
S-function name mismatch. Name in source is "#define S_FUNCTION_NAME sfun_timestwo", whereas name of the S-function MEX file is "timestwo". The source needs to be updated"
What is the meaning of the first define (S_FUNCTION_NAME)? Isn't it possible to have different S-Function names and sorce-filce names?
Thank you in advance
回答(1 个)
Walter Roberson
2015-9-2
1 个投票
No it is not. The s-function will be loaded as a .mex* (effectively a .dll), so the name used by Simulink needs to match the name of the symbol in the file.
类别
在 帮助中心 和 File Exchange 中查找有关 Create C/C++ S-Functions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!