Functions MCQ’s

Read Time:2 Minute, 19 Second

This set of MATLAB Multiple Choice Questions & Answers (MCQs) focuses on “Functions”.

1. Predominantly, what are the two kinds of errors in MATLAB programs?
a) Syntax and runtime
b) Syntax and logic
c) Logic and runtime
d) Syntax and algorithmic

2. Which code would you use to find the value of the function f?

f(x)=sin(x) + cos (x) + tan (x) at x = π/4

a) sin(45)+cos(45)+tan(45)
b) sin(pi/4)+cos(pi/4)+tan(pi/4)
c) sin(45®)+cos(45®)+sin(45®)
d) sind(45)+cosd(45)+tand(45)

3. What is the name of a primary function?
a) Name of M-file
b) Name of Script File
c) Name of Help file
d) Name of Private-File

4. Variables need to have same name while being passed from the primary function to the sub-function.
a) True
b) False

5. If the program demands evaluation of multiple, only decimal, values of the same function, what is the better way amongst the following?
a) Using anonymous functions or inline functions
b) Using str2func
c) Using private functions
d) Using any function

6. Find the error in below code.

>>f = inline('t.^4', 't');		g = inline('int(h(t), t)', 't');

a) There is no function as inline
b) The error will be in defining g
c) The error will be in evaluating a numeric value for the function g
d) Syntactical error in defining g

7. What are persistent variables?
a) Variables which retain values between calls to the function
b) Variables which help in calling a function
c) Variables which deal with functions
d) Variables global to the function

8. How do we access a global variable in nested functions?
a) Simply seek the variable from the primary function
b) Make a copy of the global variables from the primary function
c) Declare the variable within the function
d) Declare the variable as global

9. How does MATLAB help in passing function arguments?
a) By call by value and call by reference
b) Only by call by value
c) Only by call by reference
d) By call by address

10. Which command can be used for single step execution in debugging mode?
a) dbstep
b) dbstepin
c) dbstatus
d) dbcont

11. Find the error returned by MATLAB:

syms a x y;	a = xˆ2 + yˆ2;	   subs(a, [x,y], (2,3,4))

a) There is no subs command in MATLAB
b) The subs command has syntactical error
c) The subs command has extra input arguments
d) The subs command has incorrect arguments

12. Which line is treated as H1 line?
a) Comment line succeeding function definition
b) Comment line preceding function definition
c) Comment line after function
d) All lines before and after function definition

13. Predict the error, MATLAB will generate, in the following line of code:

 g = inline(‘3x+5*x’, ‘t’)

a) No error
b) Syntactical error
c) Wrong arguments
d) Expecting (,{ or [

0 %
0 %
0 %
0 %
0 %
0 %

Average Rating

5 Star
4 Star
3 Star
2 Star
1 Star

Leave a Reply

Your email address will not be published. Required fields are marked *

Previous post Vectors and Matrices – 2 MCQ’s
Next post Graphics MCQ’s