|On this page…|
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 DiscreteAdditional Discrete library contains a number of masked blocks that extend the functionality of the standard Unit Delay block. See Libraries for more general information on Simulink libraries.
The Simulink product provides a number of examples that show how to incorporate MATLAB® functions into a custom block.
The Single Hydraulic Cylinder Simulation, sldemo_hydcylsldemo_hydcyl, uses a Fcn block to model the control valve flow. In addition, the Control Valve Flow block Control Valve Flow block is a library link to one of a number of custom blocks in the library hydlibhydlib.
The Radar Tracking Model, sldemo_radarsldemo_radar, uses an Interpreted MATLAB Function block to model an extended Kalman filter. The MATLAB function aero_extkalman.maero_extkalman.m implements the Kalman filter found inside the Radar Kalman FilterRadar Kalman Filter subsystem. In this example, the MATLAB function requires three inputs, which are bundled together using a Mux block in the Simulink model.
The Spiral Galaxy Formation example, sldemo_eml_galaxysldemo_eml_galaxy, uses several MATLAB Function blocks to construct two galaxies and calculate the effects of gravity as these two galaxies nearly collide. The example also uses MATLAB Function blocks to plot the simulation results using a subset of MATLAB functions not supported for code generation. However, because these MATLAB Function blocks have no outputs, the Simulink Coder™ product optimizes them away during code generation.
The Simulink product provides a number of examples that show how to incorporate System objects into a custom block. Access the MATLAB source code for each System object™ by clicking the Source code link from the block dialog box. For more information on using MATLAB System blocks and System objects, see System Object Integration).
System Identification for an FIR System Using MATLAB System Blocks, slexSysIdentMATLABSystemExampleslexSysIdentMATLABSystemExample, uses the MATLAB System block to implement Simulink blocks using a System object. It highlights two MATLAB System blocks.
MATLAB System Block with Variable-Size Input and Output Signals, slexVarSizeMATLABSystemExampleslexVarSizeMATLABSystemExample, uses the MATLAB System block to implement Simulink blocks with variable-size input and output signals. Due to the use of variable-size signals, the example uses System object propagation methods.
Illustration of Law of Large Numbers Using MATLAB System Blocks, slexLawOfLargeNumbersExampleslexLawOfLargeNumbersExample, uses MATLAB System blocks to illustrate the law of large numbers. Due to the use of MATLAB functions not supported for code generation, the example uses System object propagation methods and interpreted execution.
The Simulink model sfundemossfundemos contains various examples of MATLAB and C MEX S-functions. For more information on writing MATLAB S-functions, see Write Level-2 MATLAB S-Functions. For more information on writing C MEX S-functions, see C/C++ S-Functions. For a list of available S-function examples, see S-Function Examples in Writing S-Functions.