| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Simulink |
| Contents | Index |
| Learn more about Simulink |
| On this page… |
|---|
Creating Custom Blocks from Masked Library Blocks |
The Additional Math and Discrete Simulink library is a group of custom blocks created by extending the functionality of built-in Simulink blocks. The Additional Discrete library contains a number of masked blocks that extend the functionality of the standard Unit Delay block. See Working with Block Libraries for more general information on Simulink libraries.
The Simulink product provides a number of demonstrations that show how to incorporate MATLAB functions into a custom block.
The Single Hydraulic Cylinder Simulation, sldemo_hydcyl.mdl, uses a Fcn block to model the control valve flow. In addition, the Control Valve Flow block is a library link to one of a number of custom blocks in the library hydlib.mdl.
The Radar Tracking Model, sldemo_radar.mdl, uses a MATLAB Fcn block to model an extended Kalman filter. The M-file aero_extkalman.m implements the Kalman filter found inside the Radar Kalman Filter subsystem. In this example, the M-file requires three inputs, which are bundled together using a Mux block in the Simulink model.
The Spiral Galaxy Formation demonstration, sldemo_eml_galaxy.mdl, uses several Embedded MATLAB Function blocks to construct two galaxy and calculate the effects of gravity as these two galaxies nearly collide. The demo also uses Embedded MATLAB Function blocks to plot the simulation results using a subset of MATLAB functions not supported for code generation. However, because these Embedded MATLAB Function blocks have no outputs, the Real-Time Workshop product optimizes them away during code generation.
The Simulink model sfundemos.mdl contains various examples of M-file and C MEX-file S-functions. For more information on writing M-file S-functions, see Writing S-Functions in M. For more information on writing C MEX S-functions, see Writing S-Functions in C. For a list of available S-function demos, see S-Function Examples in Writing S-Functions.
![]() | Tutorial: Creating a Custom Block | Using the Embedded MATLAB Function Block | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |