Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a mask for a subsystem named 'Controller'.
Simulink
maskObj = Simulink.Mask.create([1]);Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to use quotes around the subsystem name.
Using the wrong subsystem name.
✗ Incorrect
The mask is created for the subsystem named 'Controller' by passing its name as a string.
2fill in blank
mediumComplete the code to add a mask parameter named 'Gain' of type 'edit' to the mask.
Simulink
maskObj.addParameter([1], '', 'edit');
Attempts:
3 left
💡 Hint
Common Mistakes
Using a parameter name that does not exist.
Not using quotes around the parameter name.
✗ Incorrect
The parameter name 'Gain' is added to the mask as an editable field.
3fill in blank
hardFix the error in the code to set the mask display string to show the parameter 'Gain'.
Simulink
maskObj.[1] = 'disp(''Gain = '' + Gain)';
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect casing for the property name.
Using a non-existent property.
✗ Incorrect
The correct property to set the mask display is 'DisplayString' with exact casing.
4fill in blank
hardFill both blanks to add a callback that updates the mask display when the parameter changes.
Simulink
maskObj.[1] = 'maskObj.[2] = ''disp(''\''Gain = '' + Gain + ''\'')'';';
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase or singular form for 'Callbacks'.
Incorrect casing for 'DisplayString'.
✗ Incorrect
The 'Callbacks' property sets the callback code, and 'DisplayString' updates the mask display.
5fill in blank
hardFill all three blanks to create a mask parameter with a name, prompt, and type.
Simulink
maskObj.addParameter([1], [2], [3]);
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up parameter names and prompts.
Using incorrect types for the parameter.
✗ Incorrect
The parameter is named 'Gain', with prompt 'Enter gain value', and type 'edit' for user input.
