Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to open a Simulink model named 'myModel'.
Simulink
open_system('[1]')
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to put the model name in quotes.
Using the wrong model name.
Using open instead of open_system.
✗ Incorrect
The function open_system('myModel') opens the Simulink model named 'myModel'.
2fill in blank
mediumComplete the code to get the list of blocks inside the model 'myModel'.
Simulink
blocks = find_system('[1]', 'SearchDepth', 1)
Attempts:
3 left
💡 Hint
Common Mistakes
Using a subsystem name instead of the model name.
Not specifying the model name as a string.
Using 'root' which is not a valid model name.
✗ Incorrect
find_system('myModel', 'SearchDepth', 1) returns blocks at the top level of 'myModel'.
3fill in blank
hardFix the error in the code to get the parent system of block 'myModel/Subsystem1/BlockA'.
Simulink
parent = get_param('[1]', 'Parent')
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the parent system path instead of the block path.
Using only the block name without the full path.
Confusing block and system names.
✗ Incorrect
get_param('myModel/Subsystem1/BlockA', 'Parent') returns the parent system of the block.
4fill in blank
hardFill both blanks to create a list of all subsystems inside 'myModel' at any depth.
Simulink
subsystems = find_system('[1]', 'BlockType', '[2]')
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Block' or 'System' instead of 'Subsystem' for BlockType.
Using a subsystem path instead of the model name.
Not specifying BlockType parameter.
✗ Incorrect
find_system('myModel', 'BlockType', 'Subsystem') finds all subsystems inside the model.
5fill in blank
hardFill all three blanks to create a dictionary mapping subsystem names to their number of blocks inside 'myModel'.
Simulink
counts = {sys: len(find_system(sys, '[1]', '[2]')) for sys in find_system('[3]', 'BlockType', 'Subsystem')}Attempts:
3 left
💡 Hint
Common Mistakes
Using 'BlockType' instead of 'SearchDepth' for depth control.
Using wrong model or subsystem names.
Not limiting search depth causing incorrect counts.
✗ Incorrect
This code counts blocks at depth 1 inside each subsystem found in 'myModel'.
