Clear Filters
Clear Filters

Why would a Simulink disabled block still be executed?

3 views (last 30 days)
I have a MATLAB Fcn block under Simulink, that is part of a disabled subsystem. However, when I start the simulation, I've observed with the debugger that the function in question gets called during the simulation initialization, with a single 0 argument.
After some experimentation, I've observed that this behavior happens only when there's a Unit Delay block somewhere downstream from that block.
Is this a normal behavior? It causes me a lot of trouble as I'd like to disable that subsystem precisely to prevent that function from being called.

Answers (2)

Nirmal Gunaseelan
Nirmal Gunaseelan on 27 Oct 2011
The MATLAB Fcn block will be executed once before simulation to determine what the dimensions of the output will be. This will happen either during forward propagation or backward propagation and this direction might be affected by the presence of the Unit delay block. Could you try to force the dimensions to be known so that propagation doesn't alter behavior? This can be done by inserting a Signal Specification block right after the MATLAB Fcn block (or actually anywhere before the Unit delay block). Then we can see if this block is still called. The argument 0 seems most likely to be passed to find what the dimensions are.

Guy Rouleau
Guy Rouleau on 27 Oct 2011
Try setting the diagnostic "Underspecified initialization detection" to Simplified, this might help:

Categories

Find more on Configure and View Diagnostics in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

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

Start Hunting!