C-Code Level 2 S-Function Name
Show older comments
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
Answers (1)
Walter Roberson
on 2 Sep 2015
1 vote
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.
1 Comment
Hamsterfiedel
on 2 Sep 2015
Categories
Find more on Create C/C++ S-Functions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!