MATLAB Questions and Answers – Evaluation – 2

«
»

This set of Basic MATLAB Questions and Answers focuses on “Evaluation – 2”.

1. What is the output of the following code?

advertisement
feval[round’,123.12]

a) 123
b) 123.12
c) 123.1
d) Error
View Answer

Answer: d
Explanation: The input arguments to the feval command cannot be given within [], it should be included within parentheses. Hence, an error will be returned. If the input was within parentheses, the output would’ve been 123 only.
advertisement
advertisement

2. The feval command can evaluate __________
a) A single command
b) Multiple commands
c) Multiple functions
d) No such function exists
View Answer

Answer: a
Explanation: The input string argument to the feval command should contain only 1 command. If we give multiple commands to be evaluated, it will give an error.

3. The eval command can evaluate __________
a) A single function
b) Only a single command
c) The function does not exist
d) Multiple commands
View Answer

Answer: d
Explanation: The eval command can evaluate multiple commands at the same time and show their answer but it cannot assign to variables.
advertisement

4. The input to the eval command is given using [].
a) True
b) False
View Answer

Answer: b
Explanation: The input argument to the feval command is given within parentheses. Hence, MATLAB will return an error if we use [].

5. The input to the evalc command is given using {}.
a) True
b) False
View Answer

Answer: b
Explanation: The input argument to the evalc command is given within parentheses. Hence, MATLAB will return an error if we use {}.
advertisement

6. What is the value of ans from the following code?

feval(sin(0),cos(0),123)

a) 123
b) 0,1,123
c) Error
d) 0
View Answer

Answer: a
Explanation: The value of ans will keep changing after every expression gets evaluated in the string argument. So the final expression is 123 which will be the last value assigned to the ans variable.
Output: 123
advertisement

7. What is the output of the following code?

evalc(‘Laplace(t))

a) Syntactical Error
b) Symbolic error
c) ‘1/s2
d) 1/s2
View Answer

Answer: b
Explanation: There is an error in the following code. It would’ve simply evaluated the laplace transform of t which is 1/s2 but t is not defined as symbolic. Hence, MATLAB will return an error.

8. Which function gets disabled while using evalc()?
a) diary
b) sin
c) inf
d) round
View Answer

Answer: a
Explanation: The diary command gets disabled when we try to use the evalc command in MATLAB. The commands sin and round work just fine while Inf is not a function.

9. How much does the precision change while finding sin(x) using evalc and eval?
a) 10%
b) 2%
c) 20%
d) No change
View Answer

Answer: d
Explanation: The purpose of both the commands is simply to make the commands, provided in the input argument, work. They do not hamper the precision with which the commands evaluate a value.

Sanfoundry Global Education & Learning Series – MATLAB.

To practice basic 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!

advertisement
advertisement
Manish Bhojasia - Founder & CTO at Sanfoundry
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 | Youtube | Instagram | Facebook | Twitter