How do I make the 'S-function name' parameter in the S-function block variable?

I have an S-function block and I would like to have the 'S-function name' parameter as a variable that contains the name of the DLL-file (excutable for the S-function). In this way, I can modify the variable in the MATLAB workspace and do not have to change the S-function name parameter of the S-function block.

 Accepted Answer

You can use the SPRINTF function to achieve this.
For example, if the S-function name is 'myfunction', define a variable 'x' in the MATLAB workspace containing the S-function name by executing the following command at the MATLAB command prompt.
x='myfunction';
Now enter the following statement as the 'S-function name' parameter in the S-function block.
sprintf(x)
For more information on the function SPRINTF, type the following command at the MATLAB command prompt.
doc sprintf

More Answers (0)

Categories

Find more on Simulink Coder in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!