This set of MATLAB Multiple Choice Questions & Answers (MCQs) focuses 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
Explanation: 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?
d) Only if the functions are in time domain
Explanation: 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
Explanation: 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?
c) Cannot be determined
d) There is no such thing called Histogram
Explanation: 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 ___________
Explanation: 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()
Explanation: 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:
7. Can we have multiple 3d plots in MATLAB?
d) Cannot be determined
Explanation: The plot3() function is a pre-defined function in MATLAB. So, it will allow the use to generate multiple 3d plots. This is inherent to the system.
8. The student receives an error while trying to plot multiple graphs using the hold command. What is there error if there is no a syntactical error?
a) Cannot be determined
b) The plot function is not defined with a constant variable range
c) There is no hold command
d) There has to be a syntactical error only
Explanation: If the student is using the hold command, the student has to keep the scale and range of one axis same. Then he can plot the functions of other dependent variables, which depend on the independent variable range previously defined. If the plot function contains an entirely different set of arguments, MATLAB will produce an error.
9. What is the difference between hold on and hold all?
a) no difference
b) hold all holds every plot while hold on holds a specific plot in the chain of argument
c) hold all does not exist
d) hold on is syntactically incorrect
Explanation: Both hold on and hold all commands are used to hold the graph of a function. There is no difference between them. To avoid confusion, one can only write hold to hold a graph and again enter the command hold to release the graph.
10. What is the purpose of the line command if the plot command can be used to directly accept the arguments and generate a plot?
a) Saves complexity
b) We can refrain from using the hold function
c) There is no separate, definite purpose
d) Cannot conclude
Explanation: The use of the line command is primarily seen in plotting the graphs without the hold command. But we can put the arguments within the plot command itself so that we don’t have to put an extra line of code. This saves complexity, although we have increased the length of our code.
Sanfoundry Global Education & Learning Series – MATLAB.
To practice all areas of MATLAB, here is complete set of 1000+ Multiple Choice Questions and Answers.
Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!