MATLAB Questions and Answers – Two-Dimensional Plots – 1

«
»

This set of MATLAB Multiple Choice Questions & Answers (MCQs) focuses on “Two-Dimensional Plots – 1”.

1. How can we smoothen the following graph of sin (t) and cos (t) into a circle?
matlab-questions-answers-two-dimensional-plots-1-q1
a) reduce the gap between linearly spaced elements of the dependent variable t
b) reduce the gap between elements of the dependent variable t
c) increase the gap between linearly spaced elements of the dependent variable t
d) increase the gap between elements of the dependent variable t
View Answer

Answer: a
Explanation: If we reduce the gap between the linearly spaced variables of t, the curvature of sin(t) would be clearly plotted by the plot command. Hence, the resultant curve would be a circle.
advertisement

2. Which command gives a title to the graph plotted by MATLAB?
a) plot() generates the title itself
b) title()
c) hlabel()
d) heading()
View Answer

Answer: b
Explanation: The title() command is used to provide a title to the graph plotted in MATLAB. It can be provided from the taskbar of the window which opens due to the plot command.

3. Which command enables a title for the x-axis?
a) xlabel()
b) horilabel()
c) xlabel[]
d) no command
View Answer

Answer: a
Explanation: The xlabel() command is used to include a title to signify the x-axis of the graph plotted in MATLAB. Hence, the only correct option is xlabel().
advertisement
advertisement

4. Which command enables a title for the y-axis?
a) vertlabel()
b) ylabel()
c) ylabel[]
d) no command
View Answer

Answer: b
Explanation: The command ylabel is used to name the y axis of the graph plotted in MATLAB. Hence, option ylabel() is correct.

5. How can several graphs for the same function be plotted on the same window?
a) Contour plots
b) Bode plots
c) 3-D plots
d) n-D plots
View Answer

Answer: a
Explanation: Contour plots allow the plot of multiple curves of the same function on different constant levels of the function. This is extremely helpful in analyzing systems.
advertisement

6. What is the output of the following command?

meshgrid[x,y]

a) two x*y matrices
b) one x*y matrix
c) one y*x matrix
d) error
View Answer

Answer: d
Explanation: The meshgrid command takes input within a set of parentheses. Hence, the above code will show an error since the input is given in [].
advertisement

7. What is the output of the following code?

advertisement
t=0:0.001*pi:pi/2;
plot(t,sin(t),*);

a) An inverted sine curve
b) A sine curve
c) A point
d) Error
View Answer

Answer: d
Explanation: The Asterix, given as an input to the plot command, should be given within a pair of single inverted commas. Thus the above code will give an error.

8. What is the slope of the sawtooth waveform generated by the sawtooth command?
a) 1/pi
b) pi
c) 1/(2*pi)
d) 2*pi
View Answer

Answer: a
Explanation: The slope of the sawtooth waveform always has a slope of 1/pi.

9. What is the period of the sawtooth() waveform which is generated by the sawtooth() command?
a) 2*pi
b) pi*2
c) pi
d) 3*pi/2
View Answer

Answer: a
Explanation: The sawtooth() command generates a sawtooth waveform which changes it’s peak from -1 to 1 in the period 2*pi. This is inbuilt in MATLAB and so the correct answer is 2*pi.

10. The command used to generate an array of arrows is ________
a) quiver[]
b) arrows()
c) quiver()
d) arrows[]
View Answer

Answer: c
Explanation: The command quiver is used to generate an array of arrows. This command is used during plotting fields in 2-D. It is used to show the direction of strength of the field that is being plotted.

11. What is the output of the following code?

t=0:.001*pi:2*pi;
plot(cos(t),sin(t))

a) A circle
b) A straight line
c) A unit circle
d) A sinusoid
View Answer

Answer: c
Explanation: The above code generates the unit circle which is used to define the z-plane. The graph is plotted between the values of cos(t) and sin(t) over their respective time period. It won’t generate a sinusoid or a straight line.

12. The period of sinusoidal curves can be changed in MATLAB.
a) True
b) False
View Answer

Answer: a
Explanation: The sin() command is defined to generate a sinusoid with a fundamental time period of 2*pi. The period of sinusoid can be changed by changing the angular frequency while giving input to the sine command.

13. The command to draw the nature of a function over a default fundamental period is _________
a) ezplot()
b) plot()
c) stem()
d) plot3()
View Answer

Answer: a
Explanation: The plot, stem and the plot3() command does not have a default fundamental period, we need to define the period of x-axis. The ezplot command generates a plot of the input function over a default fundamental period. This fundamental period is [-2*pi,2*pi].

14. In the following code, what is the fundamental frequency of the sawtooth command?

f=1/50; sawtooth(2*pi*1/f*t)

a) 50
b) .02
c) 100
d) Error
View Answer

Answer: a
Explanation: The input to the sawtooth command is a vector which is changing with a fundamental frequency. Here, 1/f is the fundamental frequency which 50. Hence the answer is 50.

15. The limits of the axes drawn are only specified in the command used to plot the graph itself.
a) True
b) False
View Answer

Answer: b
Explanation: The axis command can be used to define the limits of the axis present on the graph that is being plotted. The x-axis of the graph would contain values according to the input to the plot/stem command but the visible part of the graph in the new window will depend on how the length of the axes are defined by the axis command.

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!

advertisement
advertisement
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn | Youtube | Instagram | Facebook | Twitter