Main Content

Use System Objects in Feedback Loops

If your algorithm needs to process nondirect feedthrough data through the System object™, use theisInputDirectFeedthroughImpl,outputImpl, andupdateImplmethods. These methods process nondirect feedthrough data through a System object.

Most System objects use direct feedthrough, where the object’s input is needed to generate the output. For these direct feedthrough objects, thestepmethod calculates the output and updates the state values. For nondirect feedthrough, however, the object’s output depends on internal states and not directly on the inputs. The inputs, or a subset of the inputs, are used to update the object states. For these objects, calculating the output is separated from updating the state values. This enables you to use an object as a feedback element in a feedback loop.

This example shows how to implement a delay object with nondirect feedthrough.

  1. In MATLAB®, selectNew>System object>Basic.

  2. SelectInsert Methodand implement theoutputImplandupdateImplmethods.

    outputImplcalculates outputs from states and/or inputs.updateImplupdates state values from inputs.

    When implementing theoutputImplmethod, do not access the System object inputs for which the direct feedthrough flag is false.

  3. If the System object supports code generation and does not use propagation, Simulink®can automatically infer the direct feedthrough settings from the System object MATLAB code. However, if the System object does not support code generation, the defaultisInputDirectFeedthroughImplmethod returns false (no direct feedthrough). In this case, override this method to specify nondirect feedthrough behavior.

The processing of the nondirect feedthrough changes the way that the software calls the System object methods within the context of the Simulink engine.

Related Topics