MATLAB Data Import and Visualization 4 β Questions and Answers
Question 1: What does setting 'Delimiter' to 'whitespace' do in MATLAB's 'readtable'?
- Treats any whitespace (spaces/tabs) as column separators (Correct answer)
- Removes all whitespace from string values
- Ignores rows that contain only whitespace
- Pads all columns to equal width with spaces
Correct answer: Treats any whitespace (spaces/tabs) as column separators
Setting Delimiter to 'whitespace' tells readtable to split columns on any sequence of spaces or tabs, useful for fixed-width or space-delimited text files.
Question 2: Which function would you use to display a matrix as a pseudocolor (heatmap) image in MATLAB?
- imagesc (Correct answer)
- image
- imshow
- surf
Correct answer: imagesc
imagesc displays matrix data as a scaled color image, automatically scaling the colormap to span the full data rangeβideal for heatmaps.
Question 3: When calling 'uiimport' in MATLAB, what is the primary use case?
- Launching a graphical Import Wizard dialog for interactive file import (Correct answer)
- Importing UI components from another figure
- Loading user interface layout files
- Importing data from a database using SQL
Correct answer: Launching a graphical Import Wizard dialog for interactive file import
uiimport opens MATLAB's Import Wizard, a GUI tool that lets users interactively preview and configure import options for various file formats.
Question 4: What is the correct way to add a color bar to a MATLAB plot?
- colorbar (Correct answer)
- addcolorbar
- legend('colorbar')
- colorscale
Correct answer: colorbar
The colorbar function adds a color scale indicator to the current axes, showing the mapping between data values and the colors displayed.
Question 5: Which MATLAB option in 'readtable' tells the function to treat the first row as variable names?
- 'VariableNamesLine', 1
- 'HeaderLines', 1
- 'ReadVariableNames', true
- Both A and C are valid (Correct answer)
Correct answer: Both A and C are valid
Both 'VariableNamesLine' (newer syntax) and 'ReadVariableNames',true (older syntax) instruct readtable to use the specified row as column headers.
Question 6: What does the MATLAB command 'axis equal' do?
- Sets the same data unit length for both axes so circles appear round (Correct answer)
- Makes x-axis and y-axis have equal tick counts
- Centers the origin at (0,0)
- Equalizes the minimum and maximum axis limits
Correct answer: Sets the same data unit length for both axes so circles appear round
'axis equal' forces the x and y axes to have the same scale (data units per pixel), ensuring geometric shapes like circles are not distorted.
Question 7: Which MATLAB function creates a 3D surface plot from X, Y, Z grid data?
- surf (Correct answer)
- mesh
- plot3
- fill3
Correct answer: surf
surf creates a shaded 3D surface using X, Y, Z grid matrices, with face colors representing Z values by default.
What does setting 'Delimiter' to 'whitespace' do in MATLAB's 'readtable'?