Bird
Raised Fist0
Simulinkdata~10 mins

Unit delay block in Simulink - Interactive Code Practice

Choose your learning style10 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a Unit Delay block in Simulink.

Simulink
unit_delay = [1]('simulink/Discrete/Unit Delay', 'model/UnitDelay');
Drag options to blanks, or click blank then click option'
Aadd_block
Bsim
Cplot
Dload_system
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'sim' instead of 'add_block' to add a block.
Using 'plot' which is for graphs, not blocks.
Using 'load_system' which loads models, not blocks.
2fill in blank
medium

Complete the code to set the initial condition of the Unit Delay block to zero.

Simulink
set_param(unit_delay, 'InitialCondition', [1]);
Drag options to blanks, or click blank then click option'
A'1'
B'NaN'
C'-1'
D'0'
Attempts:
3 left
💡 Hint
Common Mistakes
Using numeric 0 instead of string '0'.
Setting initial condition to '1' or '-1' which changes behavior.
Using 'NaN' which is not a valid initial condition.
3fill in blank
hard

Fix the error in the code to connect the Unit Delay block output to a Scope block input.

Simulink
add_line('model', 'UnitDelay/1', [1]);
Drag options to blanks, or click blank then click option'
A'Scope/1'
B'Scope/2'
C'UnitDelay/2'
D'Scope/0'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Scope/2' when the Scope has only one input.
Using 'UnitDelay/2' which is an output port, not input.
Using 'Scope/0' which is invalid port.
4fill in blank
hard

Fill both blanks to create a Unit Delay block with sample time 0.1.

Simulink
unit_delay = add_block('simulink/Discrete/[1]', 'model/UnitDelay');
set_param(unit_delay, 'SampleTime', [2]);
Drag options to blanks, or click blank then click option'
AUnit Delay
B'0.1'
C'0.01'
DDelay
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Delay' instead of 'Unit Delay' for block name.
Using numeric 0.1 instead of string '0.1' for sample time.
Using '0.01' which is a different sample time.
5fill in blank
hard

Fill all three blanks to create a Unit Delay block, set initial condition to 3, and connect it to a Scope block.

Simulink
unit_delay = add_block('simulink/Discrete/[1]', 'model/UnitDelay');
set_param(unit_delay, 'InitialCondition', [2]);
add_line('model', 'UnitDelay/1', [3]);
Drag options to blanks, or click blank then click option'
AUnit Delay
B'3'
C'Scope/1'
DDelay
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Delay' instead of 'Unit Delay' for block name.
Using numeric 3 instead of string '3' for initial condition.
Connecting to wrong port like 'Scope/2'.

Practice

(1/5)
1. What does the Unit Delay block in Simulink do?
easy
A. Outputs the previous input value, delaying the signal by one step
B. Outputs the current input value without delay
C. Outputs the sum of all past inputs
D. Outputs a random value at each step

Solution

  1. Step 1: Understand the function of Unit Delay block

    The Unit Delay block holds the input value and outputs it one time step later, effectively delaying the signal by one step.
  2. Step 2: Compare options with the definition

    Only Outputs the previous input value, delaying the signal by one step correctly describes this behavior; others describe different or incorrect behaviors.
  3. Final Answer:

    Outputs the previous input value, delaying the signal by one step -> Option A
  4. Quick Check:

    Unit Delay = previous input output [OK]
Hint: Remember: Unit Delay outputs last step's input [OK]
Common Mistakes:
  • Thinking it outputs current input immediately
  • Confusing with blocks that sum inputs
  • Assuming it outputs random or initial values only
2. Which of the following is the correct way to set the initial condition of a Unit Delay block in Simulink?
easy
A. Initialize the input signal to zero externally
B. Use a separate Gain block before the Unit Delay
C. Set the 'Initial condition' parameter in the block's dialog box
D. Set the initial condition in the MATLAB workspace only

Solution

  1. Step 1: Identify how initial conditions are set in Unit Delay

    The Unit Delay block has a parameter called 'Initial condition' in its dialog box where you specify the output value at the first time step.
  2. Step 2: Evaluate the options

    Set the 'Initial condition' parameter in the block's dialog box correctly states this method. Options B, C, and D describe indirect or incorrect ways.
  3. Final Answer:

    Set the 'Initial condition' parameter in the block's dialog box -> Option C
  4. Quick Check:

    Initial condition set inside block dialog [OK]
Hint: Set initial condition inside Unit Delay block dialog [OK]
Common Mistakes:
  • Trying to set initial condition outside the block
  • Using other blocks to simulate initial condition
  • Assuming MATLAB workspace variable sets it automatically
3. Consider a Unit Delay block with initial condition 0. The input signal over 4 time steps is [1, 3, 5, 7]. What is the output sequence?
medium
A. [1, 3, 5, 7]
B. [0, 1, 3, 5]
C. [1, 1, 3, 5]
D. [0, 0, 1, 3]

Solution

  1. Step 1: Understand Unit Delay output behavior

    At each time step, output is the input from the previous step. At step 1, output is initial condition (0).
  2. Step 2: Calculate output for each step

    Step 1 output: 0 (initial condition)
    Step 2 output: input at step 1 = 1
    Step 3 output: input at step 2 = 3
    Step 4 output: input at step 3 = 5
  3. Final Answer:

    [0, 1, 3, 5] -> Option B
  4. Quick Check:

    Output lags input by one step [OK]
Hint: Output is previous input; first output = initial condition [OK]
Common Mistakes:
  • Outputting current input instead of previous
  • Forgetting initial condition at first step
  • Shifting output incorrectly by more than one step
4. You have a Unit Delay block with initial condition 5, but the output starts at 0 instead. What is the likely cause?
medium
A. The initial condition parameter was not set correctly in the block
B. The input signal is zero at the first step
C. The Unit Delay block is connected incorrectly
D. Simulink does not support initial conditions in Unit Delay blocks

Solution

  1. Step 1: Analyze the initial condition effect

    The Unit Delay block outputs the initial condition at the first step if set properly.
  2. Step 2: Identify why output is zero instead of 5

    If output is zero, likely the initial condition parameter was not set or saved correctly in the block dialog.
  3. Final Answer:

    The initial condition parameter was not set correctly in the block -> Option A
  4. Quick Check:

    Initial condition must be set inside block [OK]
Hint: Check initial condition parameter inside block dialog [OK]
Common Mistakes:
  • Assuming input signal affects initial output
  • Thinking connection errors cause initial output zero
  • Believing Simulink ignores initial conditions
5. You want to model a system where the output at each step is the sum of the current input and the previous input. How can you use a Unit Delay block to achieve this?
hard
A. Set the initial condition of the Unit Delay block to the sum of inputs
B. Use two Unit Delay blocks in series and sum their outputs
C. Use a Unit Delay block with initial condition zero and multiply by input
D. Add the current input to the output of a Unit Delay block that delays the input by one step

Solution

  1. Step 1: Understand the requirement

    The output should be current input plus previous input value.
  2. Step 2: Use Unit Delay to get previous input

    A Unit Delay block outputs the previous input. Adding this output to the current input gives the desired sum.
  3. Step 3: Evaluate options

    Add the current input to the output of a Unit Delay block that delays the input by one step correctly describes this setup. Options A, B, and D do not produce the required output.
  4. Final Answer:

    Add the current input to the output of a Unit Delay block that delays the input by one step -> Option D
  5. Quick Check:

    Sum = current input + delayed input [OK]
Hint: Sum current input with Unit Delay output for previous input [OK]
Common Mistakes:
  • Using multiple Unit Delay blocks unnecessarily
  • Misusing initial condition to store sums
  • Multiplying instead of adding signals
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