| Writing S-Functions | ![]() |
Main Method
The body of the main function of a Level-2 M-file S-function initializes instances of the corresponding Level-2 M-File S-Function block in a model. In this respect, the main function is similar to the mdlInitializeSizes callback method implemented by C-Mex S-functions. Setup tasks that the main function performs include:
Setting up the number of input and output ports of the block.
Setting attributes such as dimensions, datatypes, complexity, and sample times for these ports.
Setting up the number of parameters and checking for the validity of these parameters.
Registering the various block methods using the handles for other local functions in the M-file, using the RegBlockMethod method of the S-function block's runtime object passed to it. See the documentation for Simulink.MSFcnRunTimeBlock for information on using this method.
| Callback Methods | Runtime Object | ![]() |
© 1994-2005 The MathWorks, Inc.