Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a button in App Designer.
MATLAB
app.Button = uibutton(app.UIFigure, '[1]');
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'slider' instead of 'push' for a button.
Using 'editfield' which is for text input, not buttons.
✗ Incorrect
The 'push' type creates a push button in App Designer.
2fill in blank
mediumComplete the code to set the button text to 'Click Me'.
MATLAB
app.Button.Text = [1];Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting the quotes around the text string.
Using a different label than requested.
✗ Incorrect
The Text property sets the label shown on the button.
3fill in blank
hardFix the error in the callback function definition for the button.
MATLAB
function [1](app, event) disp('Button clicked'); end
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'ButtonClicked' which is not the correct event name.
Using 'ButtonPress' or 'ButtonPush' which are incorrect.
✗ Incorrect
The callback function for a button push event is named 'ButtonPushed'.
4fill in blank
hardFill both blanks to create a label and set its position.
MATLAB
app.Label = uilabel(app.UIFigure); app.Label.Position = [[1] [2] 100 22];
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up x and y coordinates.
Using values too large or too small to see the label.
✗ Incorrect
The label's position is set by [x y width height]. Here x=10 and y=50.
5fill in blank
hardFill all three blanks to create a numeric edit field with a default value and label.
MATLAB
app.EditField = uieditfield(app.UIFigure, '[1]'); app.EditField.Value = [2]; app.EditField.Label = '[3]';
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'text' type instead of 'numeric' for number input.
Setting value as a string instead of a number.
Forgetting to set a label.
✗ Incorrect
The edit field type is 'numeric', default value is 10, and label is 'Enter number'.
