Bird
Raised Fist0
Simulinkdata~10 mins

Signal routing (Mux, Demux, Switch) in Simulink - Step-by-Step Execution

Choose your learning style10 modes available
Concept Flow - Signal routing (Mux, Demux, Switch)
Input Signals
↓
Single Combined Signal
↓
Separated Signals
↓
Selected Output Signal
Signal routing uses Mux to combine signals, Demux to split them, and Switch to select which signal passes through.
Execution Sample
Simulink
inputs = [1, 2, 3]
muxed = inputs  # Mux combines signals into one bus (list here)
demuxed = muxed  # Demux splits combined signal back (list here)
switched = demuxed[1]  # Switch selects signal based on control=1
print(switched)
Combines three signals, splits them back, then selects one signal based on control.
Execution Table
StepActionInputControlOutputNotes
1Input signals ready[1, 2, 3]-[1, 2, 3]Initial separate signals
2Mux combines signals[1, 2, 3]-[1, 2, 3] combinedSignals combined into one bus
3Demux splits signals[1, 2, 3] combined-[1, 2, 3]Combined signal split back
4Switch selects signal[1, 2, 3]12Control=1 selects second signal
5End--2Output is selected signal
💡 Switch outputs selected signal based on control input
Variable Tracker
VariableStartAfter Step 2After Step 3After Step 4Final
inputs[1, 2, 3][1, 2, 3][1, 2, 3][1, 2, 3][1, 2, 3]
muxed-[1, 2, 3] combined[1, 2, 3] combined[1, 2, 3] combined[1, 2, 3] combined
demuxed--[1, 2, 3][1, 2, 3][1, 2, 3]
switched---22
Key Moments - 3 Insights
Why does the Mux output look like the input list?
Mux combines signals into one bus but keeps the order; see execution_table step 2 where inputs [1, 2, 3] become a combined signal preserving order.
How does the Switch decide which signal to output?
Switch uses the control input to select one signal; in execution_table step 4, control=1 selects the second signal '2' from demuxed signals.
Why do we need Demux after Mux?
Demux splits the combined signal back into separate signals; see step 3 where combined signal is split back to [1, 2, 3].
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table at step 4, what output does the Switch produce when control=1?
A1
B2
C3
D[1, 2, 3]
💡 Hint
Check the 'Output' column at step 4 in execution_table
At which step does the Demux split the combined signal back into separate signals?
AStep 2
BStep 4
CStep 3
DStep 1
💡 Hint
Look for the action 'Demux splits signals' in execution_table
If the control input to Switch was 0 instead of 1, what would be the output at step 4?
A1
B2
C3
D[1, 2, 3]
💡 Hint
Control selects signal index; control=0 selects first signal in demuxed list
Concept Snapshot
Signal routing uses:
- Mux: combines multiple signals into one bus
- Demux: splits combined bus back to signals
- Switch: routes one input to output based on control
Control input in Switch selects which signal passes through
Used to organize and select signals in Simulink models
Full Transcript
Signal routing in Simulink uses three main blocks: Mux, Demux, and Switch. Mux takes multiple input signals and combines them into one single bus signal. Demux takes this combined bus and splits it back into separate signals. Switch selects one of the input signals to pass through to the output based on a control input. In the example, three signals [1, 2, 3] are combined by Mux, then split back by Demux, and finally Switch outputs the signal selected by the control value. This process helps organize and control signal flow in models.

Practice

(1/5)
1. What is the main purpose of a Mux block in Simulink signal routing?
easy
A. To select one signal from multiple inputs based on a condition
B. To split one signal into multiple signals
C. To combine multiple signals into one signal
D. To delay a signal by a fixed time

Solution

  1. Step 1: Understand the function of Mux

    A Mux block takes several input signals and combines them into a single output signal vector.
  2. Step 2: Compare with other blocks

    Demux splits signals, Switch selects signals, and Delay delays signals. Only Mux combines signals.
  3. Final Answer:

    To combine multiple signals into one signal -> Option C
  4. Quick Check:

    Mux combines signals = C [OK]
Hint: Mux combines signals; Demux splits; Switch selects [OK]
Common Mistakes:
  • Confusing Mux with Demux
  • Thinking Switch combines signals
  • Assuming Mux delays signals
2. Which of the following is the correct way to connect a Demux block in Simulink?
easy
A. One input signal, multiple output signals
B. Multiple input signals, one output signal
C. Multiple input signals, multiple output signals
D. One input signal, one output signal

Solution

  1. Step 1: Recall Demux block behavior

    Demux takes a single input vector signal and splits it into multiple output signals.
  2. Step 2: Match with options

    Only One input signal, multiple output signals describes one input and multiple outputs, which fits Demux.
  3. Final Answer:

    One input signal, multiple output signals -> Option A
  4. Quick Check:

    Demux splits one input to many outputs = A [OK]
Hint: Demux splits one input into many outputs [OK]
Common Mistakes:
  • Reversing input and output roles
  • Confusing Demux with Mux
  • Assuming Demux has multiple inputs
3. Given the following Simulink model snippet:
Input1 = 3;
Input2 = 7;
Input3 = 5;
mux_out = Mux([Input1, Input2, Input3]);
demux_out = Demux(mux_out);

What will be the value of demux_out[1] (the second output of Demux)?
medium
A. 3
B. Error: Index out of range
C. 5
D. 7

Solution

  1. Step 1: Understand Mux output

    Mux combines inputs [3, 7, 5] into a vector: mux_out = [3, 7, 5].
  2. Step 2: Understand Demux output

    Demux splits mux_out back into separate outputs: demux_out[0]=3, demux_out[1]=7, demux_out[2]=5.
  3. Final Answer:

    7 -> Option D
  4. Quick Check:

    Second Demux output = 7 [OK]
Hint: Mux packs inputs; Demux unpacks in same order [OK]
Common Mistakes:
  • Mixing up output indices (0-based vs 1-based)
  • Assuming Demux changes order
  • Expecting error due to indexing
4. You have a Switch block with inputs: Input1=10, Input2=20, and a control signal Control=0.
If the Switch block is configured to output Input1 when Control is 0, but the output is always 20, what is the likely error?
medium
A. Control signal logic is inverted or misconfigured
B. Input1 and Input2 are swapped in the block
C. Switch block cannot handle numeric inputs
D. Control signal is not connected

Solution

  1. Step 1: Analyze expected Switch behavior

    With Control=0, output should be Input1=10, but output is 20 (Input2).
  2. Step 2: Identify cause of wrong output

    This suggests the control logic is inverted or misconfigured, causing the block to select Input2 when Control=0.
  3. Final Answer:

    Control signal logic is inverted or misconfigured -> Option A
  4. Quick Check:

    Wrong output means control logic error = D [OK]
Hint: Check control logic polarity if Switch output is unexpected [OK]
Common Mistakes:
  • Assuming inputs are swapped without checking control
  • Thinking Switch can't handle numbers
  • Ignoring control signal connection
5. You want to build a Simulink model that takes three sensor signals and selects one to output based on a control signal (0, 1, or 2). Which combination of blocks correctly achieves this?
hard
A. Use a Demux to split sensors, then multiple Switch blocks to select output
B. Use a Mux to combine sensors, then a Multiport Switch block with control signal to select output
C. Use a Mux to combine sensors, then a Switch block with control signal to select output
D. Use three Switch blocks each connected to one sensor, controlled by the same control signal

Solution

  1. Step 1: Understand the requirement

    We need to select one of three sensor signals based on a control signal with values 0, 1, or 2.
  2. Step 2: Evaluate block combinations

    A Multiport Switch block can select one input from many based on control. Combining sensors with Mux then using Multiport Switch fits this need.
  3. Step 3: Why other options fail

    Use a Mux to combine sensors, then a Switch block with control signal to select output uses a simple Switch which only selects between two inputs, not three. Use a Demux to split sensors, then multiple Switch blocks to select output uses Demux incorrectly. Use three Switch blocks each connected to one sensor, controlled by the same control signal uses multiple Switches but control signal can't select one cleanly.
  4. Final Answer:

    Use a Mux to combine sensors, then a Multiport Switch block with control signal to select output -> Option B
  5. Quick Check:

    Multiport Switch selects among many inputs = A [OK]
Hint: Use Multiport Switch for multiple input selection [OK]
Common Mistakes:
  • Using simple Switch for more than two inputs
  • Misusing Demux for selection
  • Trying multiple Switches with one control signal
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