How can I create a Unit Delay block that accepts variable-size signals and does not need to be placed inside a conditionally executed subsystem in Simulink 7.7 (R2011a)?

29 views (last 30 days)
I have a model containing an Embedded MATLAB block which is part of an algebraic loop. This loop is broken by a Unit Delay. I now want to change the output signal of my Embedded MATLAB block to a variable-size signal. This led to the following error:
Embedded MATLAB Interface Error: Block 'Unit Delay' contains states that require resetting whenever the input signal sizes vary. This block property is inconsistent with a block property of 'Embedded MATLAB Function/ SFunction '; the output signal sizes of block 'Embedded MATLAB Function/ SFunction ' depend on its input signal values. Consider placing 'Unit Delay' in an Enabled/Function-Call/Action subsystem and setting the parameter 'Propagate sizes of variable-size signals' on the corresponding port block to: 'Only when enabling' for an Enabled or a Function-Call subsystem; or 'Only when execution is resumed' for an Action subsystem.
I followed the advice and placed the Unit Delay in an Enabled Subsystem. Since the Enabled Subsystem is atomic, the Unit Delay does not break the algebraic loop anymore. I now receive the following error: ERROR: Algebraic loop error with 'Enabled Subsystem'
I would like to introduce a delay to break an algebraic loop composed of variable-size signals.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 2 Mar 2020
Edited: MathWorks Support Team on 2 Mar 2020
As mentioned in the error message above, the Unit delay block propagates sizes only during initialization of conditionally executed subsystems. This behavior is explained here:
In order to work around this situation, it is possible to implement a different Unit Delay using an S-function.
Attached to this solution is both a Level 2 MATLAB file S-Function and a C S-function which implement a Unit Delay that does need to be placed in a conditionally executed subsystem.
Note that the attached examples illustrate one possible way to implement a Unit Delay. Depending on your specific application you may want to alter what exactly happens when the size of the variable-size signal changes to obtain the behavior you are looking for.
  1 Comment
Sandip Kumar
Sandip Kumar on 5 Dec 2013
Edited: MathWorks Support Team on 11 Jun 2018
Hi Kevin,
Sorry for the delay in responding. Unfortunately, we do not provide TLC for this C code. I would recommend you create your own TLC based on examples from the Documentation and if you need suggestions/debugging can contact our technical support by creating a service request at the following link with all the information you have :

Sign in to comment.

More Answers (0)

Categories

Find more on General Applications in Help Center and File Exchange

Tags

No tags entered yet.

Products


Release

R2011a

Community Treasure Hunt

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

Start Hunting!