C. Text property should be set after creating button
D. uifigure must be called after uibutton
Solution
Step 1: Check uibutton creation syntax
uibutton requires the parent figure as the first argument to attach the button to the window.
Step 2: Identify missing parent
The code calls uibutton('Text', 'Press') without specifying fig as parent, causing an error.
Final Answer:
Missing parent figure argument in uibutton -> Option A
Quick Check:
uibutton needs parent figure first [OK]
Hint: Always pass parent figure first to uibutton [OK]
Common Mistakes:
Forgetting to specify parent figure
Thinking Position can't be set for buttons
Calling uifigure after uibutton
5. You want to create a button that changes a label's text to 'Clicked!' when pressed. Which code snippet correctly sets up the callback in App Designer?
In App Designer, the button's callback is set using the ButtonPushedFcn property, usually assigned after creation.
Step 2: Check syntax correctness
btn = uibutton(fig, 'Text', 'Press'); btn.ButtonPushedFcn = @(btn,event) lbl.Text = 'Clicked!'; correctly creates the button then assigns ButtonPushedFcn with an anonymous function to change label text.