Matlab Plotting and Visualization Quiz

Matlab
0 Passed
0% acceptance

40 comprehensive questions on MATLAB's plotting and visualization capabilities, covering 2D/3D plots, legends, labels, titles, subplots, and figure saving techniques — with 16 code examples to master MATLAB's cpp quiz data visualization tools.

40 Questions
~80 minutes
1

Question 1

What is the basic function for creating a 2D line plot in MATLAB?

A
plot() function creates line plots connecting data points with lines
B
line() function for basic plotting
C
draw() function for plotting
D
2D plotting is not supported
2

Question 2

How do you add a title to a MATLAB plot?

matlab
x = 1:10; y = x.^2;
plot(x, y);
title('Quadratic Function');
A
Use title() function with string argument to add descriptive text above the plot
B
Titles are added automatically
C
Use name() function for plot titles
D
Titles cannot be added to plots
3

Question 3

What does the xlabel and ylabel functions do?

matlab
x = linspace(0, 2*pi, 100);
y = sin(x);
plot(x, y);
xlabel('Angle (radians)');
ylabel('Sine Value');
A
xlabel() and ylabel() add descriptive labels to x and y axes respectively for clear axis identification
B
They create new axes
C
They change axis scaling
D
Axis labels are not supported
4

Question 4

How do you create a scatter plot in MATLAB?

matlab
x = rand(50, 1);
y = rand(50, 1);
scatter(x, y);
A
Use scatter() function to create plots showing individual data points without connecting lines
B
scatter() is identical to plot()
C
Use points() function for scatter plots
D
Scatter plots are not supported
5

Question 5

What is the purpose of the legend function in MATLAB plots?

matlab
x = 1:10;
plot(x, x, 'b-', x, x.^2, 'r--');
legend('Linear', 'Quadratic');
A
legend() adds explanatory text identifying different plot elements like lines or data series for clear interpretation
B
Legend creates a new plot
C
Legend is used for axis labels
D
Legends are automatic
6

Question 6

How do you create subplots in MATLAB?

matlab
subplot(2, 2, 1);
plot(sin(1:10));
subplot(2, 2, 2);
plot(cos(1:10));
A
Use subplot() function with rows, columns, and position arguments to create multiple plots in one figure window
B
subplot() creates separate figure windows
C
Use multiplot() for subplots
D
Subplots are not supported
7

Question 7

What does the grid on command do in MATLAB plots?

matlab
x = 1:10; y = x.^2;
plot(x, y);
grid on;
A
grid on displays grid lines on the plot to help visualize data values and trends more easily
B
Grid creates a new coordinate system
C
Grid changes plot colors
D
Grid is not available in MATLAB
8

Question 8

How do you create a 3D surface plot in MATLAB?

matlab
[X, Y] = meshgrid(-2:0.1:2);
Z = X.^2 + Y.^2;
surf(X, Y, Z);
A
Use surf() function with meshgrid coordinates and z-values to create 3D surface visualizations
B
surf() is for 2D plots only
C
Use surface() function for 3D
D
3D surface plots are not supported
9

Question 9

What is the difference between plot and stem functions?

A
plot() connects points with lines, stem() shows discrete data points with vertical lines from x-axis like discrete signals
B
They are identical functions
C
stem() is for continuous data
D
plot() is for 3D data only
10

Question 10

How do you save a MATLAB figure to a file?

matlab
x = 1:10; y = x.^2;
plot(x, y);
saveas(gcf, 'myplot.png');
A
Use saveas() function with figure handle (gcf) and filename to export plots in various formats like PNG, PDF, EPS
B
Figures are saved automatically
C
Use export() function for saving
D
Figures cannot be saved to files
11

Question 11

What does the axis equal command do in MATLAB plots?

matlab
theta = linspace(0, 2*pi, 100);
x = cos(theta);
y = sin(theta);
plot(x, y);
axis equal;
A
axis equal sets equal scaling for both axes to prevent distortion and maintain proper proportions in plots
B
It makes axes the same length
C
It changes plot colors
D
axis equal is not a valid command
12

Question 12

How do you create a bar chart in MATLAB?

matlab
data = [10 20 15 25 30];
bar(data);
A
Use bar() function to create vertical bar charts displaying categorical or discrete data values
B
bar() creates line plots
C
Use bars() for bar charts
D
Bar charts are not supported
13

Question 13

What is the purpose of the hold on command?

matlab
x = 1:10;
plot(x, x, 'b');
hold on;
plot(x, x.^2, 'r');
hold off;
A
hold on allows multiple plots to be overlaid on the same axes without clearing previous plots
B
hold on creates new figure windows
C
hold on changes plot colors
D
hold on is not needed for multiple plots
14

Question 14

How do you create a histogram in MATLAB?

matlab
data = randn(1000, 1);
histogram(data);
A
Use histogram() function to visualize data distribution by showing frequency of values within specified bins
B
histogram() creates bar charts
C
Use hist() for histograms
D
Histograms are not supported
15

Question 15

What does the mesh function create in MATLAB?

matlab
[X, Y] = meshgrid(-2:0.2:2);
Z = X.*Y;
mesh(X, Y, Z);
A
mesh() creates 3D wireframe surface plots showing grid lines connecting data points for surface visualization
B
mesh() creates 2D plots
C
mesh() is for network diagrams
D
3D mesh plots are not supported
16

Question 16

How do you add text annotations to a plot?

matlab
x = 1:10; y = x.^2;
plot(x, y);
text(5, 25, 'Maximum Point');
A
Use text() function with x, y coordinates and string to add explanatory text at specific plot locations
B
Text annotations are automatic
C
Use label() for text annotations
D
Text cannot be added to plots
17

Question 17

What is the difference between figure and axes in MATLAB plotting?

A
figure is the window containing the plot, axes are the coordinate system within the figure where data is plotted
B
They are the same thing
C
axes contain the figure window
D
figure is for 3D plots, axes for 2D
18

Question 18

How do you customize line colors and styles in MATLAB plots?

matlab
x = 1:10;
plot(x, x, 'r--', x, x.^2, 'b:o');
A
Use line specification strings with color letters (r, g, b) and style symbols (--, :, -.) as third argument to plot()
B
Colors and styles are chosen automatically
C
Use separate color() and style() functions
D
Line customization is not supported
19

Question 19

What does the xlim and ylim functions control?

A
xlim() and ylim() set the range of x and y axes respectively to focus on specific data regions or set consistent scales
B
They control plot size
C
They change axis labels
D
Axis limits are automatic
20

Question 20

How do you create a contour plot in MATLAB?

matlab
[X, Y] = meshgrid(-2:0.1:2);
Z = X.^2 - Y.^2;
contour(X, Y, Z);
A
Use contour() function to create 2D representations of 3D surfaces showing lines of constant value
B
contour() creates 3D surface plots
C
Use contours() for contour plots
D
Contour plots are not supported
21

Question 21

What is the purpose of the colorbar function in MATLAB plots?

A
colorbar() adds a color scale reference showing the mapping between colors and data values in surface and contour plots
B
colorbar() changes plot colors
C
colorbar() creates new color schemes
D
Color bars are automatic
22

Question 22

How do you create multiple figures in MATLAB?

matlab
figure(1);
plot(sin(1:10));
figure(2);
plot(cos(1:10));
A
Use figure() function with numeric argument to create and switch between multiple independent figure windows
B
Multiple figures are created automatically
C
Use multi() function for multiple figures
D
Only one figure window is allowed
23

Question 23

What does the print command do for MATLAB figures?

A
print() exports figures to various file formats like PDF, PNG, EPS for publication and sharing purposes
B
print() displays figure information
C
print() creates hard copies only
D
print() is for text output
24

Question 24

How do you create a pie chart in MATLAB?

A
Use pie() function with data vector to create circular charts showing proportional relationships between data categories
B
pie() creates 3D plots
C
Use circle() for pie charts
D
Pie charts are not supported
25

Question 25

What is the difference between plotyy and plot functions?

A
plotyy() creates plots with two y-axes for displaying data with different scales on the same x-axis, while plot() uses single scale
B
They are identical functions
C
plotyy() is for 3D plots
D
plot() cannot handle multiple data series
26

Question 26

How do you add error bars to a plot?

A
Use errorbar() function with data and error values to show uncertainty or variability in data points
B
Error bars are added automatically
C
Use bars() function for error bars
D
Error bars are not supported
27

Question 27

What does the view function control in 3D plots?

A
view() sets the camera viewpoint angles (azimuth and elevation) to control 3D plot perspective and orientation
B
view() changes plot data
C
view() is for 2D plots only
D
3D view control is not supported
28

Question 28

How do you create animated plots in MATLAB?

A
Use loops with drawnow or pause to update plot data sequentially, creating animation effects for dynamic data visualization
B
Animations are created automatically
C
Use animate() function for animations
D
Animated plots are not supported
29

Question 29

What is the purpose of the clf command?

A
clf clears the current figure window, removing all plots and resetting the figure for new visualizations
B
clf closes all figure windows
C
clf changes figure colors
D
clf is not a valid command
30

Question 30

How do you create logarithmic scale plots?

A
Use semilogx(), semilogy(), or loglog() functions to create plots with logarithmic scaling on x-axis, y-axis, or both axes
B
Log scales are automatic
C
Use log() function for log plots
D
Logarithmic plots are not supported
31

Question 31

What does the shading command do in surface plots?

A
shading controls how colors are interpolated between grid points in surface plots, with options like flat, faceted, or interpolated shading
B
shading changes surface colors
C
shading is for 2D plots only
D
Surface shading is not supported
32

Question 32

How do you export figures with specific resolution?

A
Use print() function with -r option followed by DPI value to control resolution for high-quality figure export
B
Resolution is always automatic
C
Use export() with resolution parameter
D
Resolution control is not supported
33

Question 33

What is the difference between saveas and print for figure export?

A
saveas() is simpler for common formats, print() offers more control over resolution, format options, and advanced settings for professional publishing
B
They are identical functions
C
print() is for screen display
D
saveas() cannot export figures
34

Question 34

How do you create filled area plots?

A
Use area() function to create plots with filled regions under curves, useful for showing cumulative or range data
B
Filled plots are created with fill()
C
Area plots are not supported
D
Use plot() with fill option
35

Question 35

What does the zoom command do in figure windows?

A
zoom enables interactive zooming and panning in figure windows to examine plot details at different magnification levels
B
zoom changes plot data
C
zoom is for 3D plots only
D
Zoom functionality is not available
36

Question 36

How do you create box plots in MATLAB?

A
Use boxplot() function to visualize data distribution statistics including median, quartiles, and outliers for comparative analysis
B
boxplot() creates 3D plots
C
Use box() for box plots
D
Box plots are not supported
37

Question 37

What is the purpose of the datacursormode function?

A
datacursormode enables interactive data cursor for clicking on plot points to display exact x,y coordinate values and data information
B
datacursormode changes cursor appearance
C
datacursormode is for 3D plots only
D
Data cursor is not supported
38

Question 38

How do you create quiver plots for vector fields?

A
Use quiver() function with x, y coordinates and u, v components to visualize vector fields with directional arrows
B
quiver() creates regular plots
C
Use vector() for vector fields
D
Vector field plots are not supported
39

Question 39

What does the camlight command do in 3D plots?

A
camlight() adds lighting effects to 3D surfaces, creating realistic shading and depth perception in surface visualizations
B
camlight() changes camera position
C
camlight() is for 2D plots
D
3D lighting is not supported
40

Question 40

Considering MATLAB's plotting system as a whole, what fundamental concept enables its effectiveness for scientific visualization compared to basic plotting in other languages?

A
Integrated graphics system with high-level plotting functions, extensive customization options, and publication-quality output capabilities creates comprehensive visualization environment that transforms raw data into professional scientific graphics with minimal code
B
Faster rendering speed
C
Automatic plot generation
D
Built-in color schemes

QUIZZES IN Matlab