MATLAB Interface 3 — Questions and Answers
Question 1: Which MATLAB function creates a modal dialog that pauses execution until the user responds?
- uiwait (Correct answer)
- waitfor
- pause
- hold
Correct answer: uiwait
uiwait suspends execution of the calling function until the specified figure is closed or uiresume is called.
Question 2: In App Designer, which layout component automatically arranges child components in rows and columns?
- GridLayout (Correct answer)
- PanelLayout
- FlowLayout
- TableLayout
Correct answer: GridLayout
GridLayout divides the parent container into a grid and children are placed in specified row/column positions.
Question 3: What does setting the 'Enable' property of a uicontrol to 'off' do?
- Disables interaction but keeps the component visible (Correct answer)
- Hides the component
- Deletes the component
- Locks the component size
Correct answer: Disables interaction but keeps the component visible
Setting Enable to 'off' grays out the control so it is visible but cannot be interacted with by the user.
Question 4: Which MATLAB function saves a figure as an image file programmatically?
- exportgraphics (Correct answer)
- savefig
- imwrite
Correct answer: exportgraphics
exportgraphics is the recommended modern function for saving figures to formats like PNG, PDF, and EPS with fine control.
Question 5: In a MATLAB listbox (uicontrol Style='listbox'), which property holds the index of the currently selected item?
- Value (Correct answer)
- Selected
- Index
- Current
Correct answer: Value
The Value property of a listbox uicontrol stores the index (or indices for multi-select) of the selected item.
Question 6: What function do you call to force MATLAB to process pending UI events and redraw graphics?
- drawnow (Correct answer)
- refresh
- update
- repaint
Correct answer: drawnow
drawnow flushes the event queue and updates the figure, ensuring UI changes appear immediately during long computations.
Question 7: In App Designer, how do you access a UI component named 'Slider' from within a callback?
- app.Slider (Correct answer)
- this.Slider
- get(app,'Slider')
- find(app,'Slider')
Correct answer: app.Slider
All components in App Designer are properties of the app object, accessed using dot notation as app.ComponentName.
Which MATLAB function creates a modal dialog that pauses execution until the user responds?