MATLAB Questions and Answers Part-23

1. What is the short name for black as input to the surf command?
a) b
b) bl
c) k
d) blk

Answer: c
Explanation: The short name for black has been defined in MATLAB as ‘k’. So to make the color black, we need to give k as input to the surf command.

2. How do we create horizontal bar graphs in MATLAB?
a) bar3h()
b) barh()
c) bar3()
d) not possible

Answer: a
Explanation: The Bar3() command plots vertical 3-D bar graphs. The bar3h() command plots horizontal bar graphs hence bar3h() is correct.

3. The meshc() command takes complex inputs.
a) True
b) False

Answer: b
Explanation: The meshc() command does not take complex inputs. MATLAB will return an error if any such input is given.

4. colorbar command gives different color to the bar chart following their ______
a) height
b) width
c) length
d) independently

Answer: a
Explanation: The height of the bar-chart gives a measure of the data being shown. The colorbar command gives different color to the bar chart following their height.

5. The ezsurf command is present in the ___________
a) Symbolic Math Toolbox
b) Statistics and Machine Learning Toolbox
c) Partial Differentiation Equation Toolbox
d) Neural Network Toolbox

Answer: a
Explanation: The ezsurf command can be accessed from the Symbolic Toolbox. The rest of the Toolboxes does not have that command.

6. The color density of the bar-chart drawn from the bar3() command is always proportional to the height of the bars.
a) True
b) False

Answer: b
Explanation: The following statement is not necessarily true. The color density can be made inversely proportional to the height of the bars by giving the direction of color density as reverse as an input to the bar3() command.

7. A stacked horizontal bar-chart can be made in MATLAB by ___________
a) Mentioning stacked as input to the bar3() command
b) Mentioning stacked as input to the bar3h() command
c) Mentioning stack as input to the bar3[] command
d) Mentioning stacked as input to the bar3h[] command

Answer: b
Explanation: The bar3h() command is used to make a horizontal pie chart of a set of data. The bars can be stacked by giving ‘stacked’ as input to the command.

8. How can we introduce texts in a graph?
a) Use the text command
b) Use the plot command
c) Use the title command
d) Additional texts not possible

Answer: a
Explanation: The plot command will be to plot the graphs only. The title command is used to introduce a title outside the graph. A text can be introduced in a graph by using the text command.

9. What is the output of the following code?
t=linspace(0, 2*pi, .1*pi); plot(t,sin(t)); text[2,-2, ‘Ho !’];
a) a graph of sin(t)
b) a graph of inverted sin(t)
c) a graph with Ho ! written
d) error

Answer: d
Explanation: The input to the text command should be within parentheses. Here, the [] will result in an error. If a parentheses was used, the output would’ve been a graph of sin(t).

10. How many objects are created for 24 texts written in the graph?
a) 22
b) 24
c) 21
d) 2

Answer: b
Explanation: The text command would be created 24 objects in the memory for 24 texts added in the graph. It will be able to access those texts and edit them.