Why am I unable to simulate my model in accelerator mode when I have custom C-files specified in the S-Function Builder block in Simulink?

4 views (last 30 days)
I have an S-Function Builder block that specifies custom C-files in the library tab. When these C-files are named with lowercase letters, I can simulate the model in accelerator mode. However, when these C-files are named with uppercase letters, I receive the following error message:
Unable to acquire handle to MATLAB function 'test3_acc'

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
This bug has been fixed in Release 14 Service Pack 3 (R14SP3). For previous product releases, read below for any possible workarounds:
This is a bug in Simulink Performance Tool in the way that the Simulink Accelerator handles file names from the S-Function Builder block.
To work around this issue, try to specify all the S-Function modules prior to simulation.
Enter the following at the MATLAB command prompt:
set_param('$MODELNAME/S-Function Builder','SFunctionModules','<$SFUN_NAME>_wrapper $EXTERN_CODE')
where $MODELNAME is the model name.
where $SFUN_NAME is the S-function name
where $EXTERN_CODE is the library C-files, without the .c extension.
For example, I have a model named "test3", an S-function named "mysfun" and a library C-file named "afun", I would enter the following at the MATLAB command prompt:
set_param('test3/S-Function Builder','SFunctionModules','mysfun_wrapper afun')
Note that the S-Function Builder block always creates an S-function wrapper so we must specify both the wrapper and external C-files.
For more information about this, refer to the MATLAB documentation "Writing S-Functions for Real Time Workshop" by executing the following command at the MATLAB prompt:
web([docroot '/toolbox/rtw/rtw_ug/sfcn_rtw.html#67544'])

More Answers (0)

Categories

Find more on Simulink Environment Customization in Help Center and File Exchange

Products


Release

R13SP1

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!