MATLAB: How to set parameters to be tunable from the command-line when generating an S-function in Real-Time Workshop 6.6 (R2007a)

simulink coder

In my model I use Simulink.Parameter objects to specify the properties of block parameters when generating code. I need to create an S-function to protect my intellectual property when handing parts of my model to customers. Simulink.Parameter objects are tunable by default when generating an S-function, but I want some of them to be non-tunable. Since I have a lot of parameters I want to use a script-based way to declare my Simulink.Parameter objects to be tunable or non-tunable for automatic S-function generation.

Best Answer

The ability to declare a parameter relying on parameter objects to be tunable or non-tunable from the command-line when generating S-functions in not available in Real-Time Workshop 6.6 (R2007a).
As a workaround, you can create a script which performs the following steps:
1) Activate the "Inline Parameter" optimization for your model
2) Capture all parameter names which should be non-tunable in a Cell array
3) Use FIND_SYSTEM to find all the blocks which reference the parameters mentioned in step 2
4) Use SET_PARAM to replace the reference to the parameter object by the numerical value of this parameter
5) Use RTWBUILD to build the S-function for your subsystem