MATLAB Questions and Answers – Performance and Memory – 2

This set of MATLAB Multiple Choice Questions & Answers (MCQs) 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

Answer: d
Explanation: The amount of memory allotted to the Virtual Address Space of MATLAB is given as an array to q. Hence, q is correct.
advertisement

2. The function handle given to the timeit command cannot be defined within the timeit function.
a) True
b) False
View Answer

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

Answer: a
Explanation: The timeit function returns the time in seconds. Hence, the above statement is false.
Free 30-Day Java Certification Bootcamp is Live. Join Now!

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

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

advertisement
syms x;
timeit(@sin(x))

a) Syntactical Error
b) Logical Error
c) .0012
d) .0016
View Answer

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

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

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

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

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

Answer: b
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 all areas of MATLAB, here is complete set of 1000+ Multiple Choice Questions and Answers.

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). 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!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
I’m Manish - Founder and CTO at Sanfoundry. I’ve been working in tech for over 25 years, with deep focus on Linux kernel, SAN technologies, Advanced C, Full Stack and Scalable website designs.

You can connect with me on LinkedIn, watch my Youtube Masterclasses, or join my Telegram tech discussions.

If you’re in your 40s–60s and exploring new directions in your career, I also offer mentoring. Learn more here.