Matlab Plotting and Visualization Quiz
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.
Question 1
What is the basic function for creating a 2D line plot in MATLAB?
Question 2
How do you add a title to a MATLAB plot?
x = 1:10; y = x.^2;
plot(x, y);
title('Quadratic Function');Question 3
What does the xlabel and ylabel functions do?
x = linspace(0, 2*pi, 100);
y = sin(x);
plot(x, y);
xlabel('Angle (radians)');
ylabel('Sine Value');Question 4
How do you create a scatter plot in MATLAB?
x = rand(50, 1);
y = rand(50, 1);
scatter(x, y);Question 5
What is the purpose of the legend function in MATLAB plots?
x = 1:10;
plot(x, x, 'b-', x, x.^2, 'r--');
legend('Linear', 'Quadratic');Question 6
How do you create subplots in MATLAB?
subplot(2, 2, 1);
plot(sin(1:10));
subplot(2, 2, 2);
plot(cos(1:10));Question 7
What does the grid on command do in MATLAB plots?
x = 1:10; y = x.^2;
plot(x, y);
grid on;Question 8
How do you create a 3D surface plot in MATLAB?
[X, Y] = meshgrid(-2:0.1:2);
Z = X.^2 + Y.^2;
surf(X, Y, Z);Question 9
What is the difference between plot and stem functions?
Question 10
How do you save a MATLAB figure to a file?
x = 1:10; y = x.^2;
plot(x, y);
saveas(gcf, 'myplot.png');Question 11
What does the axis equal command do in MATLAB plots?
theta = linspace(0, 2*pi, 100);
x = cos(theta);
y = sin(theta);
plot(x, y);
axis equal;Question 12
How do you create a bar chart in MATLAB?
data = [10 20 15 25 30];
bar(data);Question 13
What is the purpose of the hold on command?
x = 1:10;
plot(x, x, 'b');
hold on;
plot(x, x.^2, 'r');
hold off;Question 14
How do you create a histogram in MATLAB?
data = randn(1000, 1);
histogram(data);Question 15
What does the mesh function create in MATLAB?
[X, Y] = meshgrid(-2:0.2:2);
Z = X.*Y;
mesh(X, Y, Z);Question 16
How do you add text annotations to a plot?
x = 1:10; y = x.^2;
plot(x, y);
text(5, 25, 'Maximum Point');Question 17
What is the difference between figure and axes in MATLAB plotting?
Question 18
How do you customize line colors and styles in MATLAB plots?
x = 1:10;
plot(x, x, 'r--', x, x.^2, 'b:o');Question 19
What does the xlim and ylim functions control?
Question 20
How do you create a contour plot in MATLAB?
[X, Y] = meshgrid(-2:0.1:2);
Z = X.^2 - Y.^2;
contour(X, Y, Z);Question 21
What is the purpose of the colorbar function in MATLAB plots?
Question 22
How do you create multiple figures in MATLAB?
figure(1);
plot(sin(1:10));
figure(2);
plot(cos(1:10));Question 23
What does the print command do for MATLAB figures?
Question 24
How do you create a pie chart in MATLAB?
Question 25
What is the difference between plotyy and plot functions?
Question 26
How do you add error bars to a plot?
Question 27
What does the view function control in 3D plots?
Question 28
How do you create animated plots in MATLAB?
Question 29
What is the purpose of the clf command?
Question 30
How do you create logarithmic scale plots?
Question 31
What does the shading command do in surface plots?
Question 32
How do you export figures with specific resolution?
Question 33
What is the difference between saveas and print for figure export?
Question 34
How do you create filled area plots?
Question 35
What does the zoom command do in figure windows?
Question 36
How do you create box plots in MATLAB?
Question 37
What is the purpose of the datacursormode function?
Question 38
How do you create quiver plots for vector fields?
Question 39
What does the camlight command do in 3D plots?
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?
