How to Write Custom Simulink Data Type Rules in MATLAB

Write custom data type rules as MATLAB functions, and other automatic data type propagation policies
Updated 11 Jul 2018

View License

Simulink models often begin life using purely double-precision data. As the fidelity of the model increases to include specifications of the embedded system it will be deployed on, more floating-point and fixed-point data types are often needed. Manually specifying all these data types for optimal numerical performance and system efficiency while continuing to evolve the design is time consuming and error prone.
Data type automation aims to reduce this cost. You can save time, reduce effort, apply policies, and maintain correctness by adding rules to the model to ensure data types match across signals. Construct signals with the right properties so they produce errors when your rules are violated.

This document explains how you can write your own data type rules as MATLAB functions and integrate them into your Simulink model’s data type propagation process.

Writing your own rule is the highest level of customization and requires the most expertise and resources. There are a few simpler alternatives you should consider first. Simpler out-of-the-box methods may be more compatible with the entire MathWorks tool chain (such as verification and validation products), while highly customized methods may not be completely understood by such tools.

This document describes solutions for automating data type rules in order of increasing complexity. The first section contains simple and widely capable methods. The second contains advanced techniques requiring a greater level of investment.

1. Simple techniques
a. Back-propagation
b. The Data Type Duplicate block
c. The Signal Specification block
2. More sophisticated and custom techniques
a. The Data Type Propagation block
b. Mask-controlled data type rules
c. MATLAB-authored custom data type rules

The licenses required for the demonstration models in this document are Simulink and Fixed-Point Designer. The models were tested with R2018a and may work with some earlier releases as well.

Cite As

Alexander Carmeli (2024). How to Write Custom Simulink Data Type Rules in MATLAB (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2018a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes