In Simulink® blocks, direct feedthrough means that the output of a block is controlled directly by the value of an input port signal. In nondirect feedthrough, the value of the output signal does not depend on the value of the input signal in at least one function during the simulation.
By default, MATLAB Function blocks have direct feedthrough enabled. If you disable direct feedthrough, the Simulink semantics ensure that outputs rely only on current state. Using nondirect feedthrough enables you to use MATLAB Function blocks in a feedback loop and prevent algebraic loops.
To use nondirect feedthrough:
Do not program outputs to rely on inputs or updated persistent variables. For example, do not use this code in a nondirect feedthrough block:
counter = counter + 1; % update state output = counter; % compute output based on updated state
output = counter; % compute output based on current state counter = counter + 1; % update state
If Allow direct feedthrough is disabled, you cannot call custom code functions in MATLAB Function blocks because it is not possible to enforce that the outputs of custom code functions depend only on the current state. Calling a custom code function in a MATLAB Function block triggers an error.