MATLAB Questions and Answers – Sums and Products – 1

This set of MATLAB Multiple Choice Questions & Answers (MCQs) focuses on “Sums and Products – 1”.

1. We can generate the summation of a series, formed with a character, using ________
a) symsum
b) sum
c) symssum
d) int
View Answer

Answer: a
Explanation: The in-built command to find the summation of a series generated due to a character is symsum. Since our function uses symbolic characters, we need to express our function within the symsum command to get the summation.

2. If the result of our summation is Infinity, what will MATLAB show?
a) Infinity
b) Nan
c) Inf
d) Error
View Answer

Answer: c
Explanation: The sum function is inbuilt in MATLAB. It has been developed so that if the summation of our given series becomes infinite, it will return a Inf as an output.

3. What will be the output of the following code?

advertisement
advertisement
sin(symsum(k^2,1,Inf));

a) Nan
b) Inf
c) Error
d) Output is suppressed
View Answer

Answer: d
Explanation: There is no error. MATLAB will first compute the expression within the sin() which will yield Inf. Thereafter, sin(Inf) is computed which is shown as Nan.
Note: Join free Sanfoundry classes at Telegram or Youtube

4. How does MATLAB get the symbolic character in the function, if it is not mentioned in symsum() command?
a) It cannot
b) It uses symvar()
c) It uses symsvar()
d) It uses symbvar()
View Answer

Answer: b
Explanation: If we don’t specify our symbolic variable which is in our function, the symsum() command uses the symvar() command. This command returns the set of all symbolic variables present in the function. In this way, the symsum command will continue in the execution of generating summation.

5. The sum() command cannot do ____________
a) Infinite summation
b) Numeric summation
c) Long summation
d) signed summation
View Answer

Answer: a
Explanation: The sum command always takes the total set of numbers to add. Since we cannot define a vector which extends up to Infinity, the sum() command cannot perform Infinite summation.
advertisement

6. To calculate the sum of only absolute variables in a series, we use _________
a) sum(abs())
b) abssum()
c) sumabs()
d) abs(sum())
View Answer

Answer: c
Explanation: sumabs() is a pre-defined function in MATLAB. It will select the absolute values from a series and find the summation of those values only. sum(abs()) will convert all the values in the series to their absolute values. abs(sum()) will give the absolute value of the summation.

7. What is the output of the following code?

advertisement
sumsqr([1 2; NaN 4])

a) 21
b) Nan
c) Error
d) Inf
View Answer

Answer: a
Explanation: Since Nan signifies not a number, the sumsqr() command will ignore it and generate the sum of squares of all the finite valued inputs. Hence, the answer is not Nan or Inf but 21. There is no error.
Output: 21

8. What is the output of the following code:

sumsqr([Inf Inf; Inf Inf])

a) Inf
b) Nan
c) 0
d) Error
View Answer

Answer: c
Explanation: The sumsqr only selects those values which are finite. Since we have not given any finite input to our argument matrix, the sumsqr() command will find the sum of 0 finite values. This leads to showing an output 0.
Output: 0

9. What is the output of the following code?

sumabs([Inf Inf; Inf Inf])

a) Inf
b) 0
c) Nan
d) Error
View Answer

Answer: b
Explanation: The sumabs selects finite values amongst a given series. Since we have not given any finite input to our argument matrix, the sumabs() command cannot find values to add up This leads to showing an output 0. It won’t show Inf in spite of the fact that abs(Inf) shows Inf. There is no error.

10. To find the absolute value of the sum of squares of numbers in a series, we use_________
a) abs(sumsqr())
b) sumsqr()
c) sumsqr(abs())
d) abs(sqrsum())
View Answer

Answer: a
Explanation: The command sumsqr () finds the sum of squares of finite variables in a series. If we give sumsqr(abs()), it will convert all the values in the series to absolute values so we won’t get the true sum of the series. sumsqr() will only give the sum of all the values in the series.

11. We can find the mean value of a series (upto n) using _________
a) meanabs()
b) mean()
c) sumabs()
d) sum()/n
View Answer

Answer: b
Explanation: The mean() command is an inbuilt command which can be used to compute the mean of n no. of values in a series. meanabs() will take the sum of absolute values in the series while sumabs() only computes the sum of absolute values in the series.

12. We can find the summation of an A.G.P. series using __________
a) sum()
b) symsum()
c) Depends on the series
d) Cannot be done
View Answer

Answer: b
Explanation: If the A.G.P. series can be represented as a summation of a function, we can use the symsum() to find the summation of the series. This is why MATLAB is very versatile as we can use it to reduce the time taken to solve many kinds of mathematical calculations.

13. We need to define a function separately to find the factorial of a number.
a) True
b) False
View Answer

Answer: b
Explanation: MATLAB offers the prod() function which may be used to find the factorial of a number. Hence, we don’t need to define a separate function to evaluate the factorial of a number.

14. The function to evaluate the following series is

12+22+32+42+52+…832

a) sqr()
b) sqrsum()
c) sumsqr()
d) sumsqr[]
View Answer

Answer: b
Explanation: sumsqr() is the pre-defined function is MATLAB to evaluate such series where each element is squared. sumsqr[] is syntactically incorrect.

15. What is the output of the following code?

mean[1:10]

a) Syntactical Error
b) 4.5
c) 5.5
d) Parse Error
View Answer

Answer: a
Explanation: The syntax of the mean function is mean(). Now, if we give a vector input, we can either define the vector previously or we can introduce the vector itself within []. But in the given code, we haven’t placed the vector within (). Hence the answer won’t be 5.5 but a syntactical error will be shown.

Sanfoundry Global Education & Learning Series – MATLAB.

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

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

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
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.