MATLAB Questions and Answers – Fine Tuning

«
»

This set of MATLAB Multiple Choice Questions & Answers (MCQs) focuses on “Fine Tuning”.

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
View Answer

Answer: a
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.
advertisement

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

Answer: a
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.

3. How will you return to execution from debugging mode?
a) Use the dbcont command
b) Use the return command
c) Use the dbcont & return command
d) Use the keyboard command
View Answer

Answer: c
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
View Answer

Answer: a
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?

advertisement
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
View Answer

Answer: c
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.
Output: matlab-questions-answers-fine-tuning-q5

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
View Answer

Answer: a
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
View Answer

Answer: b
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.
advertisement

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
View Answer

Answer: a
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
View Answer

Answer: a
Explanation: The pause/keyboard command is used to suspend execution for a certain time. If we press Ctrl+C, execution will be completely stopped. The end command is used to end loops of any kind.

10. The function definition is shown when we use the look for the command.
a) True
b) False
View Answer

Answer: b
Explanation: The look for command shows the H1 line used in a function. The look for command will describe only inbuilt functions and not user-defined function. The H1 line is comment line just after the function definition so the look for command does not return the function definition.

Sanfoundry Global Education & Learning Series – MATLAB.

advertisement

To practice all areas of MATLAB, here is complete set of 1000+ Multiple Choice Questions and Answers.

advertisement
advertisement
advertisement
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