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?
[p,q]=memory
a) Error
b) p
c) There’s no virtual space for MATLAB
d) q
View Answer
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.
a) True
b) False
View Answer
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.
a) True
b) False
View Answer
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
View Answer
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
c) .0012
d) .0016
View Answer
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?
a) Preallocation
b) Postallocation
c) It’s not possible to increase performance
d) Characterization
View Answer
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;
a) No
b) Yes
c) Almost
d) Error
View Answer
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?
a=timeit(()sin(x));
a) Error
b) .0012s
c) 12ms
d) .0016s
View Answer
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.
a) True
b) False
View Answer
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.
a) True
b) False
View Answer
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.
- Get Free Certificate of Merit in MATLAB
- Participate in MATLAB Certification Contest
- Become a Top Ranker in MATLAB
- Take MATLAB Tests
- Chapterwise Practice Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Chapterwise Mock Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10