Discrete transfer function in Simulink - Time & Space Complexity
We want to understand how the time it takes to compute a discrete transfer function changes as the input size grows.
Specifically, how does the number of calculations increase when the input signal length increases?
Analyze the time complexity of the following code snippet.
% Define numerator and denominator coefficients
num = [0.1 0.2 0.3];
den = [1 -0.4 0.12];
% Create discrete transfer function system
sys = tf(num, den, 0.1);
% Simulate system response for input signal u
y = lsim(sys, u, t);
This code creates a discrete transfer function and simulates its output for an input signal over time.
Identify the loops, recursion, array traversals that repeat.
- Primary operation: Calculating each output value by applying the difference equation from the transfer function.
- How many times: Once for each time step in the input signal.
Each output value depends on a fixed number of previous inputs and outputs, so the work per step stays the same.
| Input Size (n) | Approx. Operations |
|---|---|
| 10 | About 10 times the fixed calculation steps |
| 100 | About 100 times the fixed calculation steps |
| 1000 | About 1000 times the fixed calculation steps |
Pattern observation: The total work grows directly with the input length.
Time Complexity: O(n)
This means the time to compute the output grows in a straight line as the input signal gets longer.
[X] Wrong: "The time to compute the output grows faster than the input length because of repeated calculations."
[OK] Correct: Each output depends only on a fixed number of past values, so the work per step stays constant, making total time grow linearly.
Understanding how discrete transfer functions scale with input size helps you explain system simulations clearly and confidently in real projects.
"What if the transfer function had feedback loops with variable length delays? How would the time complexity change?"
Practice
Solution
Step 1: Understand the purpose of discrete transfer functions
A discrete transfer function models how the output of a system depends on its input at discrete time steps.Step 2: Eliminate unrelated options
Options about colors, hardware, or file formats do not describe system behavior.Final Answer:
The relationship between input and output in a step-by-step system -> Option CQuick Check:
Discrete transfer function = input-output relation [OK]
- Confusing transfer function with hardware settings
- Thinking it describes visual aspects
- Mixing file formats with system models
Solution
Step 1: Recall discrete transfer function definition
It requires numerator and denominator coefficient vectors plus a sample time to define the discrete system.Step 2: Check options for completeness
Only Using numerator and denominator coefficient vectors with a sample time includes numerator, denominator, and sample time, which is necessary.Final Answer:
Using numerator and denominator coefficient vectors with a sample time -> Option AQuick Check:
Numerator + denominator + sample time = correct syntax [OK]
- Omitting denominator coefficients
- Using continuous parameters for discrete blocks
- Using single scalar instead of vectors
Solution
Step 1: Calculate output at step 1 using difference equation
Output y[1] = 0.5*u[1] + 0.5*u[0] - (-0.3)*y[0]. Given u[0]=1, u[1]=0, y[0]=0 (initially), y[1] = 0.5*0 + 0.5*1 + 0.3*0 = 0.5.Step 2: Confirm initial conditions and input values
Initial output y[0] is zero, input at step 1 is zero, so calculation is correct.Final Answer:
0.5 -> Option BQuick Check:
y[1] = 0.5*0 + 0.5*1 + 0.3*0 = 0.5 [OK]
- Ignoring initial output conditions
- Using wrong input values for step 1
- Mixing numerator and denominator signs
Solution
Step 1: Validate the coefficients
Numerator [1 0] and denominator [1 -0.5] yield y[n] = u[n] + 0.5 y[n-1], which responds to input changes.Step 2: Identify the likely cause
In Simulink, if output ignores input despite valid parameters, the input signal is probably not connected to the block.Final Answer:
Input signal is not connected -> Option DQuick Check:
No response? Verify input connection [OK]
- Ignoring numerator vector meaning
- Assuming sample time zero is valid
- Not verifying input connection
Solution
Step 1: Understand delay and gain in numerator
A delay of 2 steps means the gain appears at the third coefficient (index 2), so numerator should be [0 0 0.8].Step 2: Denominator for no feedback is [1]
Since no feedback is mentioned, denominator is simply [1]. Other options have incorrect placements or values.Final Answer:
Numerator = [0 0 0.8], Denominator = [1] -> Option AQuick Check:
Delay = zeros before gain in numerator [OK]
- Placing gain at wrong numerator index
- Misunderstanding denominator role
- Confusing gain and delay positions
Ready to prove it?
Pass the test and this pattern moves unknown
