User`s guide
3 Writing S-Functions As C-MEX files
3-22
entering your S-function. Then the driving source should be connected to each
inputportasshowninthisfigure:
Checking and Processing S-Function Parameters
You can provide paramet ers to S-functions that can be changed interactively
using the
S-Function parameters field of the block’s dialog box. If you define
parameters interactively, follow these steps when you create the S-function:
1 Determine the order in which the parameters are to be specified in the
block’s dialog box.
2 InthemdlInitializeSizes function, usethe ssSetNumSFcnParams macro to
tell Simulink how many parameters are passed in to the S-function. Specify
S as the first argument and the number of parameters you are defining
interactively as the second argument.
3 Access these input arguments in the S-function using the ssGetSFcnParam
macro. Specify S as the first argument and the relative position of the
parameter in the list entered on the dialog box (0 is the first position) as the
second argument.
When you run the simulation, specify parameter names or values in the
S-Function parameters field of the block’s dialog box. The order of the
parameters names or values must be identical to the order that you defined
them in step 1 above. If you specify variable names, they do not need to be the
same as the names used in the MEX-file.
Forexample,the followingcodeis partof a devicedriver S-function.Four input
parameters are used:
BASE_ADDRESS_PRM, GAIN_RANGE_PRM, PROG_GAIN_PRM,
Source signal Mux
S-function