MATLAB Questions and Answers – Two-Dimensional Plots – 2

«
»

This set of MATLAB online test focuses on “Two-Dimensional Plots – 2”.

1. Which command is suitable to change the axes of the graph plotted?
a) axes
b) axis
c) yxaxes
d) no command
View Answer

Answer: b
Explanation: The axis command can be used to change the interchange the axes of a 2-D plot. This is easier than re=-writing the plot command already used or any other command to generate a 2-d plot. The rest of the options are incorrect.
advertisement

2. What is the output of the following code?

ezplot(x^2)

a) No such command
b) A parabola
c) A part of a parabola
d) Error
View Answer

Answer: d
Explanation: The input to the ezplot command should be given within a set of single inverted commas. Hence, the above code would give and error since the input function is not given within a ser of single inverted commas.
advertisement
advertisement

3. Which command can be used to generate multiple graphs in the same window?
a) hold on
b) wait
c) not possible without contour command
d) not possible
View Answer

Answer: a
Explanation: The command used to hold the control to an already generated graph so that further plots can be made on the same window is hold on. The contour command is used to generate graph of the same function on different levels while the hold on command is used to generate graphs of multiple functions in the same window.
advertisement

4. Inline functions can be plotted by the _________ command.
a) ezplot()
b) plot3()
c) plot()
d) cannot be done
View Answer

Answer: a
Explanation: The ezplot command takes in functions represented symbolically. The input is given as a string. So inline functions can be given as an input to the ezplot command to get a general graph of the input function.

5. Which toolbox provides the plot command?
a) Symbolic Maths Toolbox
b) Signal Processing Toolbox
c) Engineering Toolbox
d) Functions
View Answer

Answer: b
Explanation: The commands in MATLAB are stored in files called toolboxes. The plot command is stored in the Signal Processing command while the ezplot command is stored in the Symbolic Maths Toolbox.
advertisement

6. A power pattern for an antenna is a __________
a) 4-D plot of space and power
b) 3-D plot of space and power
c) 2-D plot of space and power
d) Nothing called power pattern
View Answer

Answer: c
Explanation: The power pattern of the antenna is a 2-d polar plot of the power radiated by the antenna w.r.t theta in cylindrical co-ordinates. Hence, 2-d plot of space and power is only correct.

7. The general graph of f(a,b)=0 is plotted by ______
a) ezplot()
b) plot()
c) stem()
d) not possible
View Answer

Answer: a
Explanation: A general graph of the function can be viewed by using the ezplot. If we want to define the values of a/b, we will use the plot() or stem() command. Hence, the answer is ezplot().
advertisement

8. What is the period of square wave generated by the square() command?
a) User-defined
b) pi
c) 2*pi
d) pi/2
View Answer

Answer: c
Explanation: The square waves generated by the square(0 command will always have a period of 2*pi. We can change the duty cycle of the wave but the fundamental period is 2*pi.

9. What is the output of the following code?

plot(linspace[0,3*pi],square[linspace[0,3*pi]]);

a) A square wave from 0 to 3*pi
b) A square wave with 50% duty cycle from 0 to 3*pi
c) A square wave with 50% duty cycle
d) Error
View Answer

Answer: d
Explanation: The input to the square command should be within parentheses. Here, we have not given the input vector with () and so MATLAB will show an error.

10. In a 2-d Plot, which command will make the axes of the graph same?
a) axis square
b) axis equals
c) axes square
d) axes equal
View Answer

Answer: a
Explanation: There is no such command called axes. The command axis is used to change the axes of the graph that has been plotted in MATLAB. axis equal would’ve made the axes of equal length but axis equals has equals. axis square is the only correct option.

11. What is the output of the following code?

title(‘x^2+y^2=r^2)

a) x2+y2 = r2
b) x^2+y^2 = r^2
c) Error
d) No such command
View Answer

Answer: a
Explanation: The ‘^’ is used, in the title command, to place the number as an exponent. Hence, option x2+y2 = r2 is correct. The rest of the options are incorrect.

12. What is the output of the following code?

t=linspace(0,3*pi);p=sin(t);y=cos(t);plot(t,p,t,q);

a) Error
b) Multiple plots
c) A unit circle
d) A sinusoidal
View Answer

Answer: b
Explanation: The plot command can be used to plot multiple graphs in a single window without using the hold command. The above code plots two sinusoidal curves from 0 to 3*pi. A unit circle would’ve been plotted if the plot command had only p and q as input.

13. What is the default range used by the fplot command?
a) [-5,5]
b) (-5,5)
c) No default range
d) No such command
View Answer

Answer: a
Explanation: The fplot command is almost like the ezplot command. It will plot the graph of y=f(x) within an interval [-5,5] as it was defined. This default range can be changed by giving a separate vector input to the fplot() command.

Sanfoundry Global Education & Learning Series – MATLAB.

To practice all areas of MATLAB for online tests, 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