MATLAB Interface 4 — Questions and Answers
Question 1: Which function creates a context menu that appears when a user right-clicks on a MATLAB figure object?
- uicontextmenu (Correct answer)
- rightclickmenu
- popupmenu
- contextmenu
Correct answer: uicontextmenu
uicontextmenu creates a context menu object that is attached to a graphics object via its UIContextMenu property.
Question 2: What App Designer property determines the order in which Tab key presses move focus between components?
- TabOrder (Correct answer)
- FocusOrder
- KeySequence
- NavigationOrder
Correct answer: TabOrder
TabOrder is set in App Designer's component browser or programmatically to control keyboard navigation sequence.
Question 3: Which MATLAB function displays a multi-line text input dialog and returns the string entered by the user?
- inputdlg (Correct answer)
- prompt
- textinput
- getstr
Correct answer: inputdlg
inputdlg opens a dialog with labeled text fields and returns cell array of strings entered by the user.
Question 4: In MATLAB graphics, what does setting a figure's 'WindowStyle' to 'modal' do?
- Prevents interaction with other MATLAB windows until the figure is closed (Correct answer)
- Makes the window always on top
- Locks the window size
- Hides the menu bar
Correct answer: Prevents interaction with other MATLAB windows until the figure is closed
A modal WindowStyle blocks user input to all other MATLAB windows until the modal figure is dismissed.
Question 5: Which property of a MATLAB axes object controls the text label displayed below the x-axis?
- XLabel (Correct answer)
- XTitle
- XDescription
- XCaption
Correct answer: XLabel
XLabel is an axes property that holds a text object; set XLabel.String to display a label below the x-axis.
Question 6: What is the role of the 'Tag' property in MATLAB UI components?
- Provides a string identifier to locate the component with findobj (Correct answer)
- Sets the tooltip text
- Controls the display order
- Specifies the keyboard shortcut
Correct answer: Provides a string identifier to locate the component with findobj
Tag is a user-defined string identifier that findobj can search for to retrieve a handle without storing it explicitly.
Question 7: In App Designer, which event fires when a user changes the selected tab in a TabGroup component?
- SelectionChangedFcn (Correct answer)
- TabChangedFcn
- SelectedTabFcn
- SwitchTabFcn
Correct answer: SelectionChangedFcn
SelectionChangedFcn fires on the TabGroup when the user clicks a different Tab, providing the previous and current selection.
Which function creates a context menu that appears when a user right-clicks on a MATLAB figure object?