| Using Simulink |
 |
Why Use Embedded MATLAB Function Blocks?
There are many reasons to use Embedded MATLAB Function blocks in your Simulink models. Here are just a few of them:
- Embedded MATLAB Function blocks can build stand-alone simulation applications -- To support code generation in Real-Time Workshop, the Embedded MATLAB Function block supports a subset of MATLAB commands that generate efficient C code. If you limit the function calls in Embedded MATLAB functions to subfunctions and Embedded MATLAB run-time library functions, you can use Real-Time Workshop to build simulation executables that execute without the MATLAB environment.
- Embedded MATLAB Function blocks have multiple inputs and outputs -- Unlike MATLAB Fcn blocks, which take a vector input of values and support a single scalar output, the functions in Embedded MATLAB Function blocks accept multiple inputs and return multiple outputs.
- Embedded MATLAB Function blocks inherit Simulink input and output signals -- By default, both the size and type of input and output signals to an Embedded MATLAB Function block are inherited from Simulink signals. You can also choose to specify the size and type of inputs and outputs explicitly in the Model Explorer.
- Embedded MATLAB Function blocks have the full power of MATLAB -- Using Embedded MATLAB Function blocks, developers now have access to a wide and growing variety of sophisticated mathematical applications for the embedded environment. You can choose to limit the function calls in Embedded MATLAB Function functions to subfunctions and Embedded MATLAB run-time library functions that generate efficient C code. However, for simulation applications you can call MATLAB functions directly. You can also mix function calls between run-time library functions and MATLAB functions.
- Embedded MATLAB Function blocks can replace Simulink blocks -- Some users might prefer using MATLAB code in place of Simulink block diagrams that are primarily mathematical. Also, certain classes of algorithms are more naturally expressed using a high-level language like MATLAB. For example, the following model contains a subsystem that models the air temperature in an attic space with algebraic blocks:

The following model replaces this subsystem with a single Embedded MATLAB Function block:

| What Is an Embedded MATLAB Function Block? | | Creating an Example Embedded MATLAB Function |  |
© 1994-2005 The MathWorks, Inc.