| Using Simulink |
 |
Adding an Embedded MATLAB Function Block to a Model
Start by creating an empty Simulink model and filling it with an Embedded MATLAB Function block, and other blocks necessary to complete the model.
- Create a new Simulink model and add an Embedded MATLAB Function block to it from the User-Defined Function library of the Simulink library.

- An Embedded MATLAB Function block has two names. The name in the middle of the block is the name of the function you build for the Embedded MATLAB Function block. Its name defaults to
fcn. The name at the bottom of the block is the name of the block itself. Its name defaults to Embedded MATLAB Function.
The default Embedded MATLAB Function block has an input port and an output port. The input port is associated with the input argument u, and the output port is associated with the output argument y.
- Add the following Source and Sink blocks to the model:
- From the Simulink Sources library, add a Constant block to the left of the Embedded MATLAB Function block and set its value to the vector
[2 3 4 5].
- From the Simulink Sinks library, add two Display blocks to the right of the Embedded MATLAB Function block.
- The model should now have the following appearance:

- In the Simulink window, from the File menu, select Save As and save the model as
call_stats_block1.
| Creating an Example Embedded MATLAB Function | | Programming the Embedded MATLAB Function |  |
© 1994-2005 The MathWorks, Inc.