Transfer function block in Simulink - Time & Space Complexity
We want to understand how the time to compute outputs from a transfer function block changes as the input size grows.
How does the block's processing time grow when we simulate longer or more detailed signals?
Analyze the time complexity of the following transfer function block simulation step.
% Transfer function: H(s) = (b0*s^m + ... + bm) / (a0*s^n + ... + an)
% Discretized difference equation update:
y(k) = (b0*u(k) + b1*u(k-1) + ... + bm*u(k-m))
- (a1*y(k-1) + a2*y(k-2) + ... + an*y(k-n))
This code updates the output y at each time step k using past inputs u and outputs y based on the transfer function coefficients.
Look at what repeats during simulation.
- Primary operation: Calculating y(k) using sums of past inputs and outputs.
- How many times: Once per time step for the entire input signal length.
Each new input point requires a fixed number of calculations based on the order of the transfer function.
| Input Size (n) | Approx. Operations |
|---|---|
| 10 | 10 x (order of transfer function) |
| 100 | 100 x (order of transfer function) |
| 1000 | 1000 x (order of transfer function) |
Pattern observation: Operations grow linearly with the number of input points.
Time Complexity: O(n)
This means the time to compute outputs grows in direct proportion to the number of input samples.
[X] Wrong: "The time to compute output grows faster than input size because of the feedback terms."
[OK] Correct: Each output depends on a fixed number of past values, so the work per step stays constant regardless of input length.
Understanding how simulation time scales with input size helps you design efficient models and explain performance in real projects.
"What if the transfer function order increased with input size? How would the time complexity change?"
Practice
Solution
Step 1: Understand the Transfer Function block purpose and compare options
The Transfer Function block models system behavior mathematically using polynomials. Only a mathematical model using numerator and denominator polynomials correctly describes the block.Final Answer:
A mathematical model using numerator and denominator polynomials -> Option AQuick Check:
Transfer Function = numerator/denominator polynomials [OK]
- Confusing with signal generator blocks
- Thinking it stores data instead of modeling
- Assuming it draws diagrams
Solution
Step 1: Recall Simulink syntax for polynomials and match options
Simulink requires vectors in square brackets for numerator and denominator coefficients. Only Numerator: [1 3], Denominator: [1 5 6] uses square brackets and space-separated coefficients correctly.Final Answer:
Numerator: [1 3], Denominator: [1 5 6] -> Option AQuick Check:
Use square brackets for polynomials [OK]
- Using slashes or commas instead of spaces
- Using parentheses or braces instead of brackets
- Entering fractions instead of vectors
Solution
Step 1: Determine system order from denominator degree and match to options
The denominator polynomial [1 4 4] has 3 coefficients, so degree is 2 (order = degree of denominator). A second-order system corresponds to denominator degree 2.Final Answer:
Second-order system -> Option CQuick Check:
Order = degree of denominator polynomial = 2 [OK]
- Counting number of coefficients instead of degree
- Confusing numerator degree with system order
- Assuming order from numerator length
Solution
Step 1: Analyze denominator polynomial for stability and identify cause
The denominator [1 -2 1] corresponds to (s-1)^2, which has poles at s=1 (right half-plane), causing instability. Incorrect sign in denominator coefficients leads to this.Final Answer:
Incorrect sign in denominator coefficients causing instability -> Option DQuick Check:
Poles in right half-plane cause oscillations [OK]
- Assuming numerator length causes oscillations
- Believing negative coefficients are unsupported
- Ignoring pole locations
Solution
Step 1: Identify numerator and denominator coefficients in descending powers of s
Numerator is 5s + 10, so [5 10]; denominator s^2 + 3s + 2, so [1 3 2].Final Answer:
Numerator: [5 10], Denominator: [1 3 2] -> Option BQuick Check:
Coefficients match polynomial terms in order [OK]
- Reversing coefficient order
- Mixing up numerator and denominator
- Using incorrect coefficient values
Ready to prove it?
Pass the test and this pattern moves unknown
