MATLAB Interface 2 — Questions and Answers
Question 1: Which MATLAB function opens a file selection dialog box?
- uigetfile (Correct answer)
- filedialog
- openfile
- selectfile
Correct answer: uigetfile
uigetfile opens a standard OS file selection dialog and returns the chosen filename and path.
Question 2: In MATLAB App Designer, which property controls whether a UI component is visible to the user?
- Visible (Correct answer)
- Display
- Show
- Active
Correct answer: Visible
The Visible property accepts 'on' or 'off' to show or hide a UI component in App Designer.
Question 3: What does the uicontrol function's 'Style' property set to 'slider' create?
- A horizontal or vertical draggable slider (Correct answer)
- A dropdown menu
- A toggle button
- A progress bar
Correct answer: A horizontal or vertical draggable slider
Setting Style to 'slider' in uicontrol creates a draggable slider that returns numeric values within a defined range.
Question 4: Which App Designer callback fires when the value of a numeric edit field changes and the user presses Enter or clicks away?
- ValueChangedFcn (Correct answer)
- EditingFinishedFcn
- TextChangedFcn
- InputFcn
Correct answer: ValueChangedFcn
ValueChangedFcn triggers when the NumericEditField value is committed by the user pressing Enter or losing focus.
Question 5: How do you programmatically close a MATLAB figure window?
- close(fig) (Correct answer)
- delete(fig)
- remove(fig)
- exit(fig)
Correct answer: close(fig)
close(fig) closes the specified figure window, triggering any CloseRequestFcn callbacks.
Question 6: In a MATLAB GUI, which function retrieves the value of a property from a UI object handle?
- get (Correct answer)
- getprop
- read
- fetch
Correct answer: get
get(handle, 'PropertyName') returns the current value of the specified property for any graphics or UI object.
Question 7: What is the purpose of the guidata function in GUIDE-based GUIs?
- Store and retrieve shared application data across callbacks (Correct answer)
- Create new UI components
- Launch a file dialog
- Set the GUI window title
Correct answer: Store and retrieve shared application data across callbacks
guidata stores a data structure in the figure so all callbacks can access shared state via guidata(hObject).
Which MATLAB function opens a file selection dialog box?