Feedback loop in Simulink - Time & Space Complexity
We want to understand how the time it takes to run a feedback loop in Simulink changes as the system grows.
How does the number of calculations grow when the feedback loop processes more data or steps?
Analyze the time complexity of the following feedback loop setup.
% Simulink feedback loop pseudocode
for t = 1 to N
output(t) = process(input(t), feedback(t-1));
feedback(t) = output(t);
end
This loop updates the output at each time step using the current input and the previous output as feedback.
Look at what repeats as the loop runs:
- Primary operation: The calculation of output using current input and previous feedback.
- How many times: This happens once for each time step, so N times.
As the number of time steps N increases, the total calculations increase directly with N.
| Input Size (N) | Approx. Operations |
|---|---|
| 10 | 10 calculations |
| 100 | 100 calculations |
| 1000 | 1000 calculations |
Pattern observation: The work grows in a straight line with the number of time steps.
Time Complexity: O(N)
This means the time to run the feedback loop grows directly in proportion to the number of steps.
[X] Wrong: "The feedback loop causes the time to grow faster than the number of steps because it depends on previous outputs."
[OK] Correct: Each step only uses the immediate previous output, so calculations still happen once per step, not more.
Understanding how feedback loops scale helps you explain system behavior clearly and shows you can think about performance in real projects.
"What if the feedback depended on all previous outputs instead of just the last one? How would the time complexity change?"
Practice
Solution
Step 1: Understand feedback loop concept
A feedback loop uses the output signal to influence the input, helping control system behavior.Step 2: Identify the purpose in Simulink
In Simulink, feedback loops stabilize or regulate system outputs by adjusting inputs based on output values.Final Answer:
To use the output to control the input and stabilize the system -> Option AQuick Check:
Feedback loop = control input from output [OK]
- Thinking feedback loops only display output
- Confusing feedback with feedforward
- Assuming feedback loops generate random signals
Solution
Step 1: Identify blocks that combine signals
The Sum block adds or subtracts multiple input signals, combining them into one output.Step 2: Understand feedback path creation
Feedback loops require combining signals, which the Sum block does, unlike Gain or Scope blocks.Final Answer:
Sum block -> Option AQuick Check:
Sum block combines signals [OK]
- Choosing Gain block which scales but does not combine
- Selecting Scope block which only displays signals
- Confusing Constant block with signal combiner
Solution
Step 1: Analyze Gain and Integrator effect
The Gain block multiplies input by 2, and the Integrator accumulates this value over time.Step 2: Predict output behavior
Since input is constant 1, output = integral of 2*1 = 2*t, which increases linearly over time.Final Answer:
Output will increase linearly over time -> Option CQuick Check:
Integrator accumulates scaled input linearly [OK]
- Assuming output stays constant with integrator
- Thinking output oscillates without a feedback oscillator
- Confusing exponential decrease with integration
Solution
Step 1: Understand algebraic loop error
An algebraic loop occurs when output depends directly on itself without delay, causing simulation failure.Step 2: Identify cause in feedback loops
Feedback loops need a delay or memory block to break direct dependency; missing this causes algebraic loops.Final Answer:
Missing delay or memory block in the feedback path -> Option BQuick Check:
Algebraic loop = no delay in feedback [OK]
- Blaming Sum block for algebraic loop
- Ignoring need for delay in feedback
- Thinking Scope block affects algebraic loops
Solution
Step 1: Identify blocks for feedback control
Sum block compares output with target to find error; Gain block adjusts feedback strength; Integrator accumulates error over time.Step 2: Understand how these stabilize output
Accumulated error helps correct system output gradually, stabilizing it at the target value.Final Answer:
Sum block to compare output and target, Gain block for feedback strength, and Integrator block to accumulate error -> Option DQuick Check:
Sum + Gain + Integrator = stable feedback control [OK]
- Using Scope or Constant blocks instead of error calculation
- Missing Integrator to accumulate error
- Confusing feedback with feedforward blocks
Ready to prove it?
Pass the test and this pattern moves unknown
