Mismatch Data Types Fixed-Point Tool Simulink

5 views (last 30 days)
Matteo Manzini
Matteo Manzini on 6 May 2020
Answered: Riya on 20 Jun 2025
Hello,
I am converting a Simulink model from floating-point to fixed-point. One of the subsystems in this model contains a Matlab Function.
The tool correctly proposes and applies the fixed-point types but when I simulate the model it tells me that there is a data mismatch after a signal enters in a unit delay block whose output goes into the Matlab Function. Basically the signal coming out from the delay block is a fixed-point one (and that is right) but then the Matlab function expects a double type. However, the input of the functione is correctly defined as a fixed-point type in the code I get after the proposal.
I'm attaching a couple of screenshots. I know it is a long question, hopefully someone can help me.
Thanks,
Matteo

Answers (1)

Riya
Riya on 20 Jun 2025
Hi Matteo,
The error you are encountering is due to a mismatch between the fixed-point output of the Unit Delay block and the expected double input in your MATLAB Function block. Even though the Fixed-Point Tool updates signal types, the function block may still expect double unless explicitly handled.
To fix this, make sure your MATLAB Function block handles fixed-point inputs properly. You can use a simple type check or ensure the logic works with fixed-point types:
function [flag, start_ramp] = fcn(p_lift, p_lowering, del_flag)
% Example check (optional)
assert(isa(p_lift, 'embedded.fi'), 'p_lift must be fixed-point');
% Your logic here...
end
Also, in the Model Explorer, set the data types of the inputs and outputs (e.g., flag, del_flag) to match your fixed-point type like numerictype(1,16,13), and ensure the Unit Delay block outputs the same type instead of inheriting.
After applying these changes, the simulation should work without any type mismatch issues.
For further reference, you can refer to the following official documentations:

Products

Community Treasure Hunt

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

Start Hunting!