## MATLAB Questions and Answers Part-5

1. How will one escape from printing graphs of variables, whose value gets changed for the program?
a) Use the clear all command at the beginning
b) Use the close all command at the beginning
c) Use the clc command
d) Cannot be escaped

Explanation: The clear all command keeps all the local variables of the function unaffected i.e. they prevent their values from getting changed due to some previous usage of the function. The close all command closes all the graphs the clc command removes the written code.

2. A loop is used to avoid repetitive writing of the same function in the code.
a) True
b) False

Explanation: The purpose of using loops is to avoid writing the same line multiple times. The same line may be a particular function which computes a certain value. For the sake of accuracy, we may run the function multiple times, within a loop.

a) Use the dbcont command
b) Use the return command
c) Use the dbcont & return command
d) Use the keyboard command

Explanation: While debugging, the user can choose to insert a set of instruction to change the nature of the already written program. To return to continue execution, the user can enter either dbcont or the return command.

4. The plotting of 3d plots and 2d plots requires separate windows. But the user has entered the hold on command. What is to be done?
a) Use the pause command
b) Use the hold off command
c) Use the close command
d) Nothing can be done

Explanation: The hold off command is necessary to plot multiple graphs in the same window. Thus multiple 2d graphs or multiple 3d graphs can be drawn on the same window. But the pause command is used to keep the plot of 2d graphs and wait before generating 3d graphs. The close command closes any existing graphs.

5. What will be the output of the following code?
T=-5:1:5; y=sin(T); plot(T,y)
a) No output
b) A perfect sine curve
c) A broken sine curve
d) Cannot be determined

Explanation: The sine curve is a continuous signal or a discrete signal. So the tendency of every point in the curve has to follow a radian frequency and not a step frequency. Here the frequency of time is stepping up by 1, so the sine curve will only consist of 11 values, which will lead to the sine curve appearing to be broken.

6. How would you expect to see exponential inter-relation in a logarithmic scale?
a) A straight line
b) A curved line
c) Depends on the exponent
d) Depends on the log scale

Explanation: The exponential inter-relation will appear as a straight line in a log scale. This is because logarithmic scale and exponential nature follow a linear relationship. If there are no other terms than exponentials in the expression, the graph will be a linear one.

7. There will be a problem in computing the logarithm of a negative number.
a) True
b) False

Explanation: While trying to compute a value for the logarithm of a negative number, MATLAB will return an imaginary value. We can do problems which need to compute the logarithm of a negative number.

8. Global variables must be mentioned _____ an M-file.
a) at the top in
b) anywhere in
c) out of the
d) there is nothing called global variables

Explanation: Mentioning the global variables at the top of an M-file allows the user to prevent any error rising to usage of the same variable unconsciously. If we declare it anywhere, it may so happen that we would need it at the beginning. Hence- it is plausible to declare it at the top of an M-file.

9. To stop execution, press _____
a) Ctrl+C
b) Use pause command
c) Use end command
d) Use keyboard command