Matlab Basic Plot Commands Quiz

Matlab
0 Passed
0% acceptance

35 fundamental questions on visualizing data in MATLAB, covering plot creation, customization, annotation, and saving.

35 Questions
~70 minutes
1

Question 1

Which command creates a basic 2D line plot of vector y versus vector x?

A
plot(x, y)
B
line(x, y)
C
graph(x, y)
D
draw(x, y)
2

Question 2

How do you add a title to the current plot?

A
title('My Plot')
B
header('My Plot')
C
label('My Plot')
D
plot.title = 'My Plot'
3

Question 3

Which string specifier produces a red dashed line?

A
'r--'
B
'red-dashed'
C
'r-'
D
'd-r'
4

Question 4

How do you label the x-axis?

A
xlabel('Time')
B
xtitle('Time')
C
labelx('Time')
D
axis('x', 'Time')
5

Question 5

What does the command 'grid on' do?

A
Displays grid lines on the current axes
B
Turns on the power grid simulation
C
Aligns the figure to the screen grid
D
Enables snap-to-grid
6

Question 6

Which command allows you to plot a second line on the existing axes without erasing the first one?

A
hold on
B
keep on
C
plot append
D
overlay on
7

Question 7

How do you save the current figure as a PNG image named 'result.png'?

A
saveas(gcf, 'result.png')
B
save('result.png')
C
export('result.png')
D
print -png result
8

Question 8

What does the specifier 'g:o' mean?

A
Green dotted line with circle markers
B
Grey solid line with no markers
C
Gold line with dot markers
D
Green solid line
9

Question 9

If you call 'plot(y)', what is used for the x-values?

A
Indices from 1 to the length of y
B
Indices from 0 to length-1
C
Random numbers
D
It throws an error
10

Question 10

Which command closes all open figure windows?

A
close all
B
clear all
C
clc
D
exit
11

Question 11

How do you specify a line width of 2 points?

A
plot(x, y, 'LineWidth', 2)
B
plot(x, y, 'Width', 2)
C
plot(x, y, 2)
D
style(x, y, 2)
12

Question 12

What is the color code for black in MATLAB plotting?

A
'k'
B
'b'
C
'bl'
D
'bk'
13

Question 13

How do you create a new, empty figure window?

A
figure
B
newplot
C
window
D
open
14

Question 14

Which command adds a legend to the plot?

A
legend('Label1', 'Label2')
B
key('Label1', 'Label2')
C
map('Label1', 'Label2')
D
names('Label1', 'Label2')
15

Question 15

What does 'axis equal' do?

A
Sets the aspect ratio so that one data unit is the same length in both x and y
B
Makes the x and y limits the same
C
Centers the plot
D
Removes the axes
16

Question 16

How can you plot multiple datasets in a single command?

A
plot(x1, y1, x2, y2)
B
plot([x1, x2], [y1, y2])
C
plot(x1, y1) + plot(x2, y2)
D
multiplot(x1, y1, x2, y2)
17

Question 17

Which function is used to create a grid of subplots within a single figure?

A
subplot(m, n, p)
B
gridplot(m, n, p)
C
multiplot(m, n, p)
D
layout(m, n, p)
18

Question 18

How do you turn on minor grid lines?

A
grid minor
B
grid small
C
minor on
D
grid(2)
19

Question 19

What is the default line style in MATLAB?

A
Solid line ('-')
B
Dashed line ('--')
C
Dotted line (':')
D
No line (markers only)
20

Question 20

Which command sets the range of the x-axis manually?

A
xlim([min, max])
B
xrange([min, max])
C
axis x [min, max]
D
setx([min, max])
21

Question 21

How do you plot discrete data points without connecting lines?

A
plot(x, y, 'o')
B
scatter(x, y)
C
Both A and B
D
plot(x, y, 'none')
22

Question 22

What does 'clf' do?

A
Clears the current figure
B
Clears the command line
C
Closes the figure
D
Clears functions
23

Question 23

How do you change the font size of the title?

A
title('Text', 'FontSize', 14)
B
title('Text', 14)
C
set(title, 14)
D
font('Text', 14)
24

Question 24

Which command is used to export graphics with high resolution suitable for publication?

A
exportgraphics(gcf, 'file.pdf', 'ContentType', 'vector')
B
savehighres('file.pdf')
C
printscreen
D
hdplot('file.pdf')
25

Question 25

What is the marker specifier for a square?

A
's'
B
'sq'
C
'box'
D
'q'
26

Question 26

How do you stop adding to the current plot (release the hold)?

A
hold off
B
hold stop
C
release
D
end hold
27

Question 27

What does 'axis tight' do?

A
Sets the axis limits to the range of the data
B
Removes whitespace around the figure
C
Locks the axes
D
Makes the lines thinner
28

Question 28

Which property controls the color of the line?

A
'Color'
B
'LineColor'
C
'c'
D
'Fill'
29

Question 29

How do you add a text label at specific coordinates (x, y)?

A
text(x, y, 'My Label')
B
label(x, y, 'My Label')
C
annotate(x, y, 'My Label')
D
put(x, y, 'My Label')
30

Question 30

What does 'yyaxis right' do?

A
Activates a second y-axis on the right side
B
Moves the y-axis to the right
C
Rotates the plot
D
Plots only positive y values
31

Question 31

How do you make the axes box complete (lines on top and right)?

A
box on
B
axis box
C
border on
D
frame on
32

Question 32

What is the result of 'plot(x, y, 'LineWidth', 3, 'Color', [0 0.5 0])'?

A
A thick dark green line
B
A thin red line
C
Error
D
A dotted blue line
33

Question 33

Which command allows you to click on the plot to get coordinates?

A
ginput
B
getcoords
C
click
D
input
34

Question 34

How do you create a logarithmic scale on the x-axis?

A
set(gca, 'XScale', 'log')
B
semilogx(x, y)
C
Both A and B
D
logx(x, y)
35

Question 35

What does 'gca' stand for?

A
Get Current Axes
B
Get Current Array
C
Global Coordinate Axis
D
Graphic Control Area

QUIZZES IN Matlab