MATLAB: How to make the ‘S-function name’ parameter in the S-function block variable

evaluatesimulinksprintf

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.

Best 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