Different ways of incorporating M-code into Simulink
Contents
Naming conventions
*_mlfcn.* using the MATLAB Fcn block (has supporting M-files)
*_fcn.* using the FCN block
*_L1_msfcn.* using Level-1 M-file S-functions (has supporting M-files)
*_L2_msfcn.* using Level-2 M-file S-functions (has supporting M-files)
*_eml.* using Embedded MATLAB (debugging has been disabled)
*_ss.* using native Simulink blocks
Example 1. aero_radar_*.mdl
The model files aero_radar_*.mdl all implement the same Kalman filter for estimating aircraft position from a radar measurement.
These models also call MATLAB to generate the plots you see while they are running.
ls aero_radar_*.mdl
aero_radar_L2_msfcn.mdl aero_radar_eml.mdl aero_radar_mlfcn.mdl
The supporting m-files are
- the implementation of the Kalman filter
ls aero_extkalman_*.m
aero_extkalman_L2_msfcn.m aero_extkalman_mlfcn.m
- the implmentation of the plotting code
ls aero_plot_*.m
aero_plot_L2_msfcn.m aero_plot_mlfcn.m
When run, these models display the elapsed time for intialization and the complete simulation. Run them several times as subsequent
runs are typically faster than the first one. You may also consider removing the plotting code if you want to measure the
raw numerical performance.
Example 2. eqn_sim_*.mdl
The model files eqn_sim_*.mdl implements the mass-flow rate equation
from the demo model fuelsys.mdl.
ls eqn_sim_*.mdl
eqn_sim_L1_msfcn.mdl eqn_sim_eml.mdl eqn_sim_mlfcn.mdl
eqn_sim_L2_msfcn.mdl eqn_sim_fcn.mdl eqn_sim_ss.mdl
If you have a license for the Simulink Accelerator these models will bring up the Simulink Profiler to show elapsed time when
the simulation completes.