Bird
Raised Fist0
Simulinkdata~10 mins

Mixed continuous-discrete models in Simulink - Step-by-Step Execution

Choose your learning style10 modes available
Concept Flow - Mixed continuous-discrete models
Start Simulation
↓
Initialize Continuous States
↓
Compute Continuous Derivatives
↓
Integrate Continuous States
↓
Update Discrete States
↓
Output Calculation
↓
Check Stop Condition
Yes↓
End Simulation
↩Back to Compute Continuous Derivatives
The simulation alternates between computing continuous state changes and updating discrete states, looping until the stop condition is met.
Execution Sample
Simulink
1. Initialize continuous and discrete states
2. Compute derivatives of continuous states
3. Integrate continuous states over time step
4. Update discrete states at sample times
5. Calculate outputs
6. Repeat until simulation end
This sequence shows how Simulink handles mixed continuous and discrete parts step-by-step during simulation.
Execution Table
StepActionContinuous StatesDiscrete StatesOutputNotes
1Initialize statesx=0.0d=0y=0Start with zero states
2Compute derivativesdx/dt=2.0d=0y=0Derivative based on current x
3Integrate continuous statesx=0.02d=0y=0x updated by integration over 0.01s
4Update discrete statesx=0.02d=1y=0Discrete state updated at sample time
5Calculate outputx=0.02d=1y=2.02Output depends on x and d
6Check stop conditionx=0.02d=1y=2.02Simulation continues
7Compute derivativesdx/dt=2.04d=1y=2.02Next derivative calculation
8Integrate continuous statesx=0.04d=1y=2.02x integrated again
9Update discrete statesx=0.04d=2y=2.02Discrete state increments
10Calculate outputx=0.04d=2y=4.04Output updated
11Check stop conditionx=0.04d=2y=4.04Simulation continues
12............Process repeats until end time
NStop simulationx=finald=finaly=finalSimulation time reached
💡 Simulation stops when the predefined simulation time or stop condition is met.
Variable Tracker
VariableStartAfter Step 3After Step 4After Step 8After Step 9Final
x (continuous state)0.00.020.020.040.04final value
d (discrete state)00112final value
y (output)0002.024.04final value
Key Moments - 3 Insights
Why does the continuous state 'x' update smoothly while the discrete state 'd' changes suddenly?
Because continuous states are integrated over small time steps (see steps 2 and 3), they change gradually. Discrete states update only at specific sample times (step 4), causing sudden jumps.
How does the simulation decide when to update discrete states?
Discrete states update at fixed sample times during the simulation loop (step 4 and 9), independent of continuous integration steps.
Why is output 'y' calculated after both continuous and discrete states update?
Output depends on the latest values of both continuous and discrete states, so it is computed after both have been updated (steps 5 and 10).
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table at step 4. What is the value of the discrete state 'd' after update?
A1
B2
C0
DUndefined
💡 Hint
Check the 'Discrete States' column at step 4 in the execution table.
At which step does the continuous state 'x' first increase from 0.0?
AStep 1
BStep 3
CStep 2
DStep 4
💡 Hint
Look at the 'Continuous States' column and find when x changes from 0.0.
If the discrete state update was delayed by one step, how would the output 'y' at step 5 change?
AIt would be higher
BIt would remain the same
CIt would be lower
DIt would be zero
💡 Hint
Output depends on both continuous and discrete states; delaying discrete update means output uses older discrete value.
Concept Snapshot
Mixed continuous-discrete models combine smooth continuous state changes with sudden discrete updates.
Continuous states are integrated over small time steps.
Discrete states update at fixed sample times.
Outputs depend on both state types and update after both states change.
Simulation loops through these steps until stop condition.
Full Transcript
In mixed continuous-discrete models, the simulation starts by initializing continuous and discrete states. Then it computes derivatives of continuous states and integrates them over small time steps, causing smooth changes. Discrete states update suddenly at fixed sample times. Outputs are calculated after both continuous and discrete states update. This loop repeats until the simulation stop condition is met. Continuous states change gradually, while discrete states jump at sample times. Outputs reflect the latest state values. Understanding this flow helps in modeling systems with both continuous dynamics and discrete events.

Practice

(1/5)
1. What does a mixed continuous-discrete model in Simulink represent?
easy
A. A system combining smooth continuous changes and stepwise discrete changes
B. A system with only continuous changes
C. A system with only discrete changes
D. A system that cannot be simulated in Simulink

Solution

  1. Step 1: Understand model types in Simulink

    Continuous models change smoothly over time, discrete models change at specific time steps.
  2. Step 2: Define mixed continuous-discrete model

    It combines both smooth continuous changes and stepwise discrete changes in one system.
  3. Final Answer:

    A system combining smooth continuous changes and stepwise discrete changes -> Option A
  4. Quick Check:

    Mixed model = continuous + discrete changes [OK]
Hint: Mixed models combine smooth and step changes [OK]
Common Mistakes:
  • Thinking mixed means only continuous
  • Confusing discrete with continuous
  • Believing Simulink can't simulate mixed models
2. Which Simulink block is used to represent discrete-time memory in mixed models?
easy
A. Integrator
B. Unit Delay
C. Gain
D. Sum

Solution

  1. Step 1: Identify discrete memory blocks

    Discrete memory stores previous values at discrete time steps.
  2. Step 2: Match block to function

    Unit Delay block holds the input value for one discrete time step, acting as memory.
  3. Final Answer:

    Unit Delay -> Option B
  4. Quick Check:

    Discrete memory = Unit Delay [OK]
Hint: Unit Delay stores previous discrete values [OK]
Common Mistakes:
  • Choosing Integrator which is continuous
  • Confusing Gain with memory
  • Selecting Sum which adds signals
3. Consider a Simulink model with an Integrator block connected to a Unit Delay block. If the input is a step signal starting at 0 and stepping to 1 at time 1s, what is the output of the Unit Delay block at time 1.5s?
medium
A. 0.5
B. 0
C. 1
D. Undefined

Solution

  1. Step 1: Understand signal timing

    The step input changes from 0 to 1 at 1s.
  2. Step 2: Analyze Unit Delay output at 1.5s

    Unit Delay outputs the input value from the previous discrete time step. Assuming sample time 1s, at 1.5s it outputs input at 1s, which is 1 after the step.
  3. Final Answer:

    1 -> Option C
  4. Quick Check:

    Unit Delay outputs previous step input [OK]
Hint: Unit Delay outputs previous step input value [OK]
Common Mistakes:
  • Assuming Unit Delay outputs current input
  • Ignoring sample time effect
  • Confusing Integrator output with Unit Delay
4. You have a mixed model with an Integrator and Unit Delay connected, but the simulation shows unexpected zero output from the Unit Delay. What is the most likely cause?
medium
A. Sample time of Unit Delay is not set correctly
B. Integrator block is not connected to Unit Delay
C. Step input is constant zero
D. Gain block is missing

Solution

  1. Step 1: Check connections

    If Integrator not connected, output would be undefined, not zero.
  2. Step 2: Verify Unit Delay sample time

    If sample time is incorrect or continuous, Unit Delay may output zero because it never updates.
  3. Final Answer:

    Sample time of Unit Delay is not set correctly -> Option A
  4. Quick Check:

    Incorrect sample time causes zero output [OK]
Hint: Check Unit Delay sample time for updates [OK]
Common Mistakes:
  • Assuming connection issue without checking sample time
  • Ignoring input signal values
  • Thinking Gain block affects Unit Delay output
5. You want to model a system where a continuous temperature sensor feeds into a controller that updates every 0.1 seconds using discrete logic. Which approach correctly combines continuous and discrete parts in Simulink?
hard
A. Use only continuous blocks and ignore discrete timing
B. Use only discrete blocks with sample time 0.1s for both sensor and controller
C. Use a Unit Delay for temperature and Integrator for controller
D. Use an Integrator for temperature and a Unit Delay with sample time 0.1s for controller updates

Solution

  1. Step 1: Identify continuous and discrete parts

    Temperature sensor is continuous, controller logic updates discretely every 0.1s.
  2. Step 2: Choose appropriate blocks

    Integrator models continuous sensor output; Unit Delay with sample time 0.1s models discrete controller updates.
  3. Final Answer:

    Use an Integrator for temperature and a Unit Delay with sample time 0.1s for controller updates -> Option D
  4. Quick Check:

    Continuous sensor + discrete controller = Integrator + Unit Delay [OK]
Hint: Integrator for continuous, Unit Delay for discrete timing [OK]
Common Mistakes:
  • Using only discrete blocks for continuous sensor
  • Ignoring sample time for discrete controller
  • Reversing block roles
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