Sample M-Script for Configuring Model Function Prototypes
The following sample M-script configures the model function
prototypes for the rtwdemo_counter model,
using the Function Prototype Control Functions.
%% Open the rtwdemo_counter model
rtwdemo_counter
%% Select ert.tlc as the System Target File for the model
set_param(gcs,'SystemTargetFile','ert.tlc')
%% Create a model-specific C function prototype
a=RTW.ModelSpecificCPrototype
%% Add argument configuration information for Input and Output ports
addArgConf(a,'Input','Pointer','inputArg','const *')
addArgConf(a,'Output','Pointer','outputArg','none')
%% Attach the model-specific C function prototype to the model
attachToModel(a,gcs)
%% Rename the initialization function
setFunctionName(a,'InitFunction','init')
%% Rename the step function and change some argument attributes
setFunctionName(a,'StepFunction','step')
setArgPosition(a,'Output',1)
setArgCategory(a,'Input','Value')
setArgName(a,'Input','InputArg')
setArgQualifier(a,'Input','none')
%% Validate the function prototype against the model
[status,message]=runValidation(a)
%% if validation succeeded, generate code and build
if status
rtwbuild(gcs)
end
 | Configuring Model Function Prototypes Programmatically | | Verifying Generated Code for Customized Functions |  |
Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
Get this Simulink Kit