Bird
Raised Fist0
Simulinkdata~10 mins

First-order system simulation in Simulink - Step-by-Step Execution

Choose your learning style10 modes available
Concept Flow - First-order system simulation
Define system parameters
↓
Set initial conditions
↓
Apply input signal
↓
Compute system response step
↓
Update system state
↓
Check simulation time
↓
End simulation
The simulation starts by setting parameters and initial state, then repeatedly computes the system response over time until the simulation ends.
Execution Sample
Simulink
tau = 5;
K = 2;
u = 1;  % step input
x = 0;  % initial state
for t = 0:1:10
  dx = (-(x) + K * u) / tau;
  x = x + dx;
  disp([t, x])
end
This code simulates a first-order system response to a step input over 10 seconds with 1-second steps.
Execution Table
Time (t)State (x)Derivative (dx)ActionOutput
000.4Calculate dx = (-(0) + 2*1)/5 = 0.4x updated to 0 + 0.4 = 0.4
10.40.32Calculate dx = (-(0.4) + 2*1)/5 = 0.32x updated to 0.4 + 0.32 = 0.72
20.720.256Calculate dx = (-(0.72) + 2*1)/5 = 0.256x updated to 0.72 + 0.256 = 0.976
30.9760.205Calculate dx = (-(0.976) + 2*1)/5 = 0.205x updated to 0.976 + 0.205 = 1.181
41.1810.164Calculate dx = (-(1.181) + 2*1)/5 = 0.164x updated to 1.181 + 0.164 = 1.345
51.3450.131Calculate dx = (-(1.345) + 2*1)/5 = 0.131x updated to 1.345 + 0.131 = 1.476
61.4760.105Calculate dx = (-(1.476) + 2*1)/5 = 0.105x updated to 1.476 + 0.105 = 1.581
71.5810.084Calculate dx = (-(1.581) + 2*1)/5 = 0.084x updated to 1.581 + 0.084 = 1.665
81.6650.067Calculate dx = (-(1.665) + 2*1)/5 = 0.067x updated to 1.665 + 0.067 = 1.732
91.7320.054Calculate dx = (-(1.732) + 2*1)/5 = 0.054x updated to 1.732 + 0.054 = 1.786
101.7860.043Calculate dx = (-(1.786) + 2*1)/5 = 0.043x updated to 1.786 + 0.043 = 1.829
💡 Simulation ends after t=10 seconds as loop completes
Variable Tracker
VariableStartAfter 1After 2After 3After 4After 5After 6After 7After 8After 9After 10
x00.40.720.9761.1811.3451.4761.5811.6651.7321.786
dx0.40.320.2560.2050.1640.1310.1050.0840.0670.0540.043
Key Moments - 3 Insights
Why does the state x not jump immediately to the steady value 2?
Because the system is first-order with time constant tau=5, it changes gradually. Each step adds a fraction of the difference, as shown in execution_table rows where x increases slowly.
Why is dx smaller at later times?
dx depends on the difference between current x and steady input effect. As x gets closer to steady state, the difference shrinks, so dx gets smaller (see execution_table dx values decreasing).
What happens if we increase the time step from 1 to 2 seconds?
The state updates would be larger jumps, possibly less accurate. The simulation steps would be fewer but each dx calculation would cover more time, changing the values in execution_table.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table at time t=3, what is the state x?
A1.185
B0.976
C0.72
D1.352
💡 Hint
Check the 'State (x)' column at row where 'Time (t)' is 3 in execution_table
At which time step does the derivative dx first drop below 0.1?
A7
B5
C6
D8
💡 Hint
Look at the 'Derivative (dx)' column in execution_table and find first value less than 0.1
If the input u changes from 1 to 0 at t=5, what happens to dx at t=6?
Adx becomes zero
Bdx stays positive
Cdx becomes negative
Ddx doubles
💡 Hint
Recall dx formula depends on input u; if u=0, dx = (-x + 0)/tau, which is negative if x>0
Concept Snapshot
First-order system simulation:
- Model: dx/dt = ( -x + K*u ) / tau
- Simulate by discrete steps: x += dx * dt
- dx depends on current state and input
- State approaches steady value gradually
- Smaller time steps give smoother results
Full Transcript
This visual execution traces a first-order system simulation in Simulink style. We start by defining parameters tau=5, gain K=2, and a step input u=1. The initial state x is zero. At each time step from 0 to 10 seconds, we calculate the derivative dx as ( -x + K*u ) / tau, then update x by adding dx. The execution table shows how x and dx change over time, with x gradually increasing towards the steady state value of 2. Key moments clarify why x changes slowly and why dx decreases as x approaches steady state. The visual quiz tests understanding of state values at specific times and effects of input changes. The snapshot summarizes the simulation approach and key rules for first-order systems.

Practice

(1/5)
1. What does a first-order system simulation in Simulink typically show?
easy
A. How the system output changes over time after an input
B. The exact solution of differential equations analytically
C. The internal code of Simulink blocks
D. The hardware specifications of the computer running Simulink

Solution

  1. Step 1: Understand the purpose of first-order system simulation

    It models how the output of a simple system changes over time when given an input.
  2. Step 2: Identify what simulation shows in Simulink

    Simulink simulates the system response graphically, showing output behavior over time.
  3. Final Answer:

    How the system output changes over time after an input -> Option A
  4. Quick Check:

    Simulation = output change over time [OK]
Hint: Simulation shows output change over time [OK]
Common Mistakes:
  • Confusing simulation with code details
  • Thinking simulation shows hardware specs
  • Assuming simulation gives exact analytic solutions
2. Which of the following is the correct way to represent a first-order transfer function in Simulink's Transfer Function block?
easy
A. Numerator: [5], Denominator: [1 0]
B. Numerator: [1 5], Denominator: [1]
C. Numerator: [1], Denominator: [1 5]
D. Numerator: [1], Denominator: [5 1]

Solution

  1. Step 1: Recall first-order transfer function form

    A first-order system has denominator of form s + a, so denominator coefficients are [1 a].
  2. Step 2: Match numerator and denominator arrays

    Numerator is usually constant [1], denominator [1 5] means s + 5, correct for first-order.
  3. Final Answer:

    Numerator: [1], Denominator: [1 5] -> Option C
  4. Quick Check:

    Denominator = [1 a] for first-order [OK]
Hint: Denominator starts with 1 for s term [OK]
Common Mistakes:
  • Swapping numerator and denominator
  • Using wrong order of coefficients
  • Using zero in denominator leading coefficient
3. Given the Simulink Transfer Function block with Numerator = [2] and Denominator = [1 3], and a step input of magnitude 1, what is the steady-state output value?
medium
A. 2
B. 0.67
C. 0.5
D. 3

Solution

  1. Step 1: Calculate steady-state gain from transfer function

    Steady-state gain = numerator constant / denominator constant = 2 / 3 ≈ 0.67.
  2. Step 2: Apply step input magnitude

    Step input is 1, so output steady-state = 0.67 * 1 = 0.67.
  3. Final Answer:

    0.67 -> Option B
  4. Quick Check:

    Gain = 2/3 = 0.67 [OK]
Hint: Steady-state = numerator/denominator constant term [OK]
Common Mistakes:
  • Using numerator over denominator reversed
  • Ignoring step input magnitude
  • Confusing transient with steady-state
4. You created a first-order system in Simulink with Numerator = [1] and Denominator = [1 0], but the simulation shows no response. What is the likely error?
medium
A. Denominator [1 0] represents an integrator, not a first-order system
B. Numerator should be zero for first-order systems
C. Step input magnitude is missing
D. Scope block is not connected

Solution

  1. Step 1: Analyze denominator [1 0]

    Denominator [1 0] means s + 0 = s, which is an integrator, not a first-order system with constant term.
  2. Step 2: Understand simulation behavior

    Integrator causes output to ramp, but if input is zero or setup wrong, no visible response occurs.
  3. Final Answer:

    Denominator [1 0] represents an integrator, not a first-order system -> Option A
  4. Quick Check:

    Denominator must have constant term for first-order [OK]
Hint: Denominator must have constant term, not zero [OK]
Common Mistakes:
  • Assuming zero constant term is valid
  • Ignoring block connections
  • Forgetting to set step input
5. You want to simulate a first-order system with time constant 4 seconds and gain 3 in Simulink. Which numerator and denominator coefficients should you use in the Transfer Function block?
hard
A. Numerator: [1], Denominator: [1 0.25]
B. Numerator: [3], Denominator: [4 1]
C. Numerator: [3], Denominator: [1 0.25]
D. Numerator: [3], Denominator: [1 4]

Solution

  1. Step 1: Write transfer function formula for first-order system

    Transfer function = gain / (time_constant * s + 1) = 3 / (4s + 1).
  2. Step 2: Convert to Simulink coefficients

    Numerator [3], Denominator [1 4] for s + 4.
  3. Final Answer:

    Numerator: [3], Denominator: [1 4] -> Option D
  4. Quick Check:

    Denominator = [1 tau] for first-order [OK]
Hint: Denominator coefficients = [1 tau] [OK]
Common Mistakes:
  • Swapping numerator and denominator
  • Using time constant as denominator constant
  • Not normalizing denominator leading coefficient to 1
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard