Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to set the gain value of a Gain block in Simulink.
Simulink
set_param('model/Gain', 'Gain', '[1]');
Attempts:
3 left
💡 Hint
Common Mistakes
Using the block name instead of the gain value.
Not using quotes around the gain value.
✗ Incorrect
The 'Gain' parameter expects a string representing the gain value, such as '5'.
2fill in blank
mediumComplete the code to get the value of the 'SampleTime' parameter from a block.
Simulink
sampleTime = get_param('model/Integrator', '[1]');
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Gain' instead of 'SampleTime'.
Using incorrect parameter names.
✗ Incorrect
The 'SampleTime' parameter returns the sample time setting of the block.
3fill in blank
hardFix the error in the code to set the 'InitialCondition' parameter of a block.
Simulink
set_param('model/Memory', 'InitialCondition', [1]);
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a numeric value without quotes.
Using the parameter name as the value.
✗ Incorrect
The parameter value must be a string, so the number 0 should be in quotes.
4fill in blank
hardFill both blanks to create a dictionary of block parameters and their values.
Simulink
params = struct('[1]', '5', '[2]', '10');
Attempts:
3 left
💡 Hint
Common Mistakes
Using block type names instead of parameter names.
Mixing parameter names with values.
✗ Incorrect
The struct has keys 'Gain' and 'SampleTime' with their respective values.
5fill in blank
hardFill all three blanks to set multiple parameters of a block at once.
Simulink
set_param('model/Sum', '[1]', '+-', '[2]', 'on', '[3]', 'off');
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect parameter names.
Mixing parameter values and names.
✗ Incorrect
The parameters 'Inputs', 'ShowName', and 'Lock' are set with their respective values.
