MATLAB Multiple Choice Questions on “Plotting Multiple Curves”.
1. A student has created a plot of y(t)=t2. He is need to show another graph of z(t)=t3 in the same plot. But every time he hits the plot() function- MATLAB generates a plot of z(t) vs t but on a different window. What is the error?
a) It is not possible to plot multiple plots
b) He is not using the line function
c) Maybe he is using stem() instead of plot()
d) He is not using the hold function
Answer: d
Clarification: The hold command is used to hold the cursor, developed after creating a plot, so that the next graph, when plotted, will appear on the same window where the initial graph was plotted. He may use the line function, but in the code he is using the plot function. So he has to enter the function hold before plotting the graph of z(t).
2. Does the plot function take multiple arguments to a plot?
a) True
b) False
c) Sometimes
d) Only if the functions are in time domain
Answer: a
Clarification: The plot function can take multiple input arguments to plot multiple graphs. This is an inbuilt function so the nature of the function is, inherently, to take multiple arguments if the arguments are defined.
3. What happens if we don’t stop the implementation of the hold function?
a) Nothing happens
b) MATLAB keeps on generating multiple plots in the same window
c) Error is generated
d) Plot function won’t work
Answer: b
Clarification: Suppose we plot 2 graphs on the same window by using the hold command. If we don’t stop the implementation of the hold function, MATLAB will keep on generating plots on the same window. So the user won’t get a separate plot if he wants.
4. Is histogram a kind of multiple plots?
a) True
b) False
c) Cannot be determined
d) There is no such thing called Histogram
Answer: a
Clarification: We are plotting a particular data set for different entities. The data set may comprise of the same set but each entity is inherently independent from each other. So, we are plotting multiple functions of the same variables. Hence, the histogram is a kind of multiple plots.
5. The function to plot vector fields is ___________
a) quiver()
b) pie3
c) ezplot()
d) contour()
Answer: a
Clarification: The function ‘quiver()’ is a pre-defined function in MATLAB. It is often used to plot vector fields in MATLAB. The pie3 function is used to plot a 3-d pie plot. The ezplot() generates a 3d plot while the contour() is used to generate the contour plot of a specified matrix.
6. How to introduce a title to describe the subplots generated in MATLAB?
a) Use a function
b) Use the title function
c) Use the legend function
d) Use uipanel()
Answer: d
Clarification: The uipanel can be used to give a major title to the subplots created. The title name is given as a string input by the following way:
f=figure;
c=uipanel(‘Parent’,f,’BorderType’,’none’);
c.Title=’Title Name’;
c.TitlePosition=’centertop’
7. Can we have multiple 3d plots in MATLAB?
a) Yes
b) No
c) Maybe
d) Cannot be determined
