Complete the code to create a Unit Delay block in Simulink.
unit_delay = [1]('simulink/Discrete/Unit Delay', 'model/UnitDelay');
The add_block function is used to add a Unit Delay block to the Simulink model.
Complete the code to set the initial condition of the Unit Delay block to zero.
set_param(unit_delay, 'InitialCondition', [1]);
The initial condition for the Unit Delay block is set as a string. Setting it to '0' means the delay starts with zero.
Fix the error in the code to connect the Unit Delay block output to a Scope block input.
add_line('model', 'UnitDelay/1', [1]);
The connection must be from the Unit Delay block output port 1 to the Scope block input port 1, which is 'Scope/1'.
Fill both blanks to create a Unit Delay block with sample time 0.1.
unit_delay = add_block('simulink/Discrete/[1]', 'model/UnitDelay'); set_param(unit_delay, 'SampleTime', [2]);
The block name is 'Unit Delay' and the sample time must be a string, here '0.1'.
Fill all three blanks to create a Unit Delay block, set initial condition to 3, and connect it to a Scope block.
unit_delay = add_block('simulink/Discrete/[1]', 'model/UnitDelay'); set_param(unit_delay, 'InitialCondition', [2]); add_line('model', 'UnitDelay/1', [3]);
The block name is 'Unit Delay', initial condition is string '3', and connection is to 'Scope/1'.
