Why do I get an error when trying to feed enumerated data types through a 'Unit Delay' block?
36 views (last 30 days)
Show older comments
MathWorks Support Team
on 20 Jan 2022
Answered: MathWorks Support Team
on 17 Feb 2022
In Simulink (R2021b), I have a signal that carries enumerated data into a 'Unit Delay' block. I then use the output of the 'Unit Delay' block elsewhere in my model. However, when I try to run my model, I get the following error:
'<my_model>/Unit Delay' cannot convert parameter InitialCondition from data type 'double' to data type '<MyEnumType>' because conversion of parameters with enumerated data types is not supported.
The documentation page for 'Unit Delay' says that enumerated data is supported, so what is causing this error and how can I resolve it?
Accepted Answer
MathWorks Support Team
on 20 Jan 2022
This error is caused by the fact that the 'Initial Condition' parameter of the unit delay block is not of the same type as the inputted enumerated signal. When the model first runs, the value of the 'Initial Condition' parameter is passed through the model, so the 'Unit Delay' block expects data of the same type to be continuously fed into it. The next time step, when the enumerated data is fed in, the error is thrown since the data type of the input is different than the data type of the initial condition.
Change the initial condition of the 'Unit Delay' block to be an enumerated type value.
Please see the model fails.slx for a demonstration of the issue, and the model works.slx for a solution to this issue.
0 Comments
More Answers (0)
See Also
Categories
Find more on Sources in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!