MATLAB Questions and Answers Part-12

1. How will we integrate a non-linear function, f, taken as an inline function?
a) int([f])
b) quad(‘f’)
c) quad([f])
d) quad(‘[f]’)

Answer: d
Explanation: The function, f, will be taken as a string input. Hence, we cannot use the int command since it takes symbolic arguments while the class of our function is inline. Since the function is non-linear, we need to introduce it as a matrix to our quad() command. It takes string arguments so the correct answer should be quad(‘[]’).

2. The correct way of using the quad command while integrating an inline non-linear function is __________
a) quad(‘[]’)
b) quad([‘’])
c) quad([])
d) quad(‘’)

Answer: a
Explanation: The inline function, being a non-linear function and saved as an inline class, will be given as a string argument to the quad() command. Due to its non-linear nature, it has to be placed like a matrix. quad(‘’) will only take the function but the function is non-linear so it will show an error. quad([‘’]) is wrong because the ‘’ should comprise the entire function, hence it should be outside []. quad([]) is syntactically wrong.

3. What is the class of the result of quad() command?
a) Long
b) Short
c) Double
d) Unsigned

Answer: c
Explanation: The class of the result of quad command is double. This is an in-built command in MATLAB and it will give the answer in the format double.

4. What is the output of the following code?
s=23;p=90;z=p-s;int(x^-exp(-Inf),p,z)
a) -23
b) 67
c) 0
d) Error

Answer: d
Explanation: We need to declare x as a symbolic variable before using it in the int() command. The input argument to the int() command should be symbolic. The answer would be -23 if we had declared symbolic before using the int() command.

5. The int function returns a constant of integration for indefinite integration.
a) True
b) False

Answer: b
Explanation: The int function does not return a constant of integration after doing indefinite integration. It will only show the particular integral after integrating the input function.

6. The answer for indefinite integration in MATLAB is __________
a) The only possible particular integral
b) One of the many possible integrals
c) 0
d) erroneous

Answer: b
Explanation: Indefinite integrals can have many possible solutions. Only of the solution is provided by the int() function.

7. What is the output of the following code?
int(int(x^2))
a) x^4/12
b) x^4/16
c) 0
d) Error

Answer: d
Explanation: We have to give symbolic arguments to our int() command. Since we have not declared x as symbolic, the result of the int command will be an error. If the ‘x’ was declared as symbolic, the result would’ve been x^4/12.

8. We cannot perform problems regarding area under a curve in MATLAB.
a) True
b) False

Answer: b
Explanation: We can do problems pertaining to finding the area under a curve in MATLAB. This is because methods of definite and indefinite integration are present in the form of commands in MATLAB. This makes MATLAB so versatile.

9. What is the class of the result of quadl() command?
a) double
b) short
c) long
d) symbolic

Answer: a
Explanation: The class of the result of quadl() command is double since it computes definite integrals only. We would get the result as symbolic if we compute indefinite integration using the int command.

10. To find the particular integral of a differential equation, we use the _____
a) int() command
b) quad() command
c) ODE solver
d) Depends on the differential equation

Answer: d
Explanation: We can find the particular integral for the differential equation dydx=5x by using int(5*x). We would need an ODE solver when the differential equation is long and has multiple orders. Hence, it depends on the differential equation, how we want to select our command.