This set of Advanced MATLAB Questions and Answers focuses on “Performance and Memory – 2”.
1. Which of the following contains the memory for the virtual address space given to MATLAB?
c) There’s no virtual space for MATLAB
Explanation: The amount of memory allotted to the Virtual Address Space of MATLAB is given as an array to q. Hence, q is correct.
2. The function handle given to the timeit command cannot be defined within the timeit function.
Explanation: The function handle can be given as an input to the timeit() command. It’s not necessary that we need a separate variable to declare a function handle.
3. The timeit function returns the time in ms.
Explanation: The timeit function returns the time in seconds. Hence, the above statement is false.
4. What is the output of the following code?
syms x; timeit(@()sin(x))
a) The time required to compute the value of a sin(x)
b) Error due to sin(x)
c) Syntactical Error
d) Time required to initialize sin(x) as a vector of symbolic elements
Explanation: Since x is declared as symbolic, the function sin(x) will only initialize itself as sin(x), It doesn’t compute a specific value and hence the time required for initializing sin(x) as a vector of symbolic elements is correct.
5. What is the output of the following code?
syms x; timeit(@sin(x))
a) Syntactical Error
b) Logical Error
Explanation: The function handle has been declared with an error. A set of parentheses is missing. TH e function handle is defined as @()sin(x). Hence, the above code will give an error.
6. Which of the following method increases the performance of operation?
c) It’s not possible to increase performance
Explanation: The method of preallocation helps in increasing the performance of memory. It can be used to specifically increase the speed of the operation.
7. Is a==c?
>>a=timeit(@()sin(x)); >>b=cputime; >>sin(x); >>c=cputime-b;
Explanation: The time calculated and assigned to c is usually more than that in a. This is because the cpu time increases in the third statement only. Hence the option, which says that a is not equal to c is correct.
8. What is the output of the following code?
Explanation: There is an error in the above code. The function handle has been wrongly decalred since the ‘@’ is missing. Hence the option, which says there will be an error, is correct.
9. The amount of memory saved for swap files is more than the physical memory allotted for MATLAB.
Explanation: The latter is always greater than the former. This is because the physical memory is getting used up during operations.
10. The tick command starts a timer.
Explanation: The command is misspelled. The correct command is tic only. Hence, the above statement is false.
Sanfoundry Global Education & Learning Series – MATLAB.
To practice advanced questions and answers on 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!