Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to load a referenced model named 'controller'.
Simulink
load_system('[1]');
Attempts:
3 left
💡 Hint
Common Mistakes
Using a generic name instead of the actual model name.
Forgetting to put the model name in quotes.
✗ Incorrect
The function load_system requires the exact name of the referenced model to load it into memory.
2fill in blank
mediumComplete the code to set the parameter 'StopTime' of a referenced model to '10'.
Simulink
set_param('[1]', 'StopTime', '10');
Attempts:
3 left
💡 Hint
Common Mistakes
Using the base model name instead of the referenced block name.
Misspelling the block name.
✗ Incorrect
The referenced model block is usually named with '_ref' suffix; here 'controller_ref' is the correct block name.
3fill in blank
hardFix the error in the code to update the referenced model's parameter 'Solver' to 'ode45'.
Simulink
set_param('[1]', 'Solver', 'ode45');
Attempts:
3 left
💡 Hint
Common Mistakes
Using the base model name instead of the referenced block name.
Using an incorrect block name.
✗ Incorrect
The referenced model block name must be used, which is 'controller_ref' here.
4fill in blank
hardFill both blanks to create a dictionary of referenced models and their load status.
Simulink
status = { '[1]': isLoaded('[2]') };Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up referenced block names and base model names.
Using the same name for both key and value.
✗ Incorrect
The dictionary key is the referenced block name, and the value checks if the base model is loaded.
5fill in blank
hardFill all three blanks to create a list comprehension of referenced models with StopTime greater than 5.
Simulink
models = [m for m in [1] if get_param(m, '[2]') [3] '5']
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect parameter names.
Using wrong comparison operators.
Not using the correct iterable variable.
✗ Incorrect
The list comprehension filters referenced models where the 'StopTime' parameter is greater than '5'.
