MATLAB Questions and Answers Part-11

1. Which rule does MATLAB use while differentiating a set of functions?
a) u-v rule
b) by parts
c) no pre-defined rule
d) not possible

Answer: a
Explanation: If we give an argument within our command diff() which is a product of multiple functions or division of two functions; we will get the result that will be generated according to the u-v rule. This makes MATLAB very versatile for the applications concerning differentiation.

2. There is no difference between a difference equation and a differential equation.
a) True
b) False

Answer: b
Explanation: There are many differences between a difference equation and a differential equation. But the most important would be that a difference equation takes finite steps of changes of our changing variable while a differential equation takes an infinitesimal change in our changing variable.

3. For the existence of the nth (n is varying from 1 to until the derivative is becoming 0) derivative of an equation, the equation should have __________
a) Initial values
b) At least one independent variable
c) At least one dependent variable
d) No such condition

Answer: b
Explanation: Derivatives are calculated with respect to a change in an independent variable. Hence for deriving a derivative- the equation should have at least one independent variable so that we can find the derivative with respect to a change in that independent variable.

4. What will be the output of the following code?
syms x;diff(sin(x)\x2)
a) (2*x)/sin(x) – (x2*cos(x))/sin(x)2
b) cos(x)/x2 – (2*sin(x))/x3
c) x2*cos(x) + 2*x*sin(x)
d) Error

Answer: a
Explanation: We observe that sin(x)\x2 has a back slash. This, in MATLAB, implies that x2 is divided by sin(x). Hence the answer is (2*x)/sin(x) – (x2*cos(x))/sin(x)2. If it would have been a front slash, the answer would have been cos(x)/x2 – (2*sin(x))/x3. If there was a ‘*’ sign, the answer would have been ‘x2*cos(x) + 2*x*sin(x)’.

5. What is the data type of y?
y=diff(x2*cos(x) + 2*x*sin(x))
a) Symbolic
b) Double
c) Array
d) Symbolic Array

Answer: d
Explanation: Every element saved in the workspace is stored as an array. The class of the array will be symbolic for y since we haven’t specified a value for x. If we give a value of x, y will be stored as Double.

6. The output for diff(p2,q) is _______
a) 0
b) 2*p
c) 2 dp/dq
d) Error

Answer: a
Explanation: We are differentiating the function ‘p2’ with respect to q. Hence the value will be 0. The 2nd argument in the diff() command is the variable, with respect to which- we differentiate our function.

7. What does the following code do?
syms m,y,x,c;
a) Calculate m
b) Calculate slope
c) Error
d) Calculate divergence

Answer: c
Explanation: While using syms, we can’t instantiate multiple symbolic variables using a comma. We will have to enter them with space in between. Hence MATLAB returns an error. If we remove the comma, the code will calculate the slope of ‘y=mx+c’.

8. What is the nature of ode45 solver?
a) 2nd ordered R-K solver
b) 4th ordered R-K solver
c) 1st order R-K solver
d) Adams solver

Answer: b
Explanation: The ode45 solver is an Ordinary Differential Equation solver in MATLAB which is used to solve a differential equation using the Runga-Kutta or R-K method upto 4th order. This is an inbuilt ODE solver in MATLAB.

9. Ordinary differential equations having initial values ____________
a) Can be solved
b) Cannot be solved
c) Can be modelled
d) Has a trivial solution

Answer: c
Explanation: We have 8 different Ordinary differential equations solvers in MATLAB. They take the initial values, if at all present, into account while solving the Differential equation of interest. Hence, systems which follow a differential equation can be modelled and observed using MATLAB.

10. The current characteristics of RC networks are better analyzed by Laplace than differentiation methods.
a) True
b) False

Answer: b
Explanation: We use the Laplace method to ease the process of solving a differential equation. But, with the help of MATLAB- we can solve them very fast. So, it is obvious to use the ODE solver to calculate the current through the capacitor in RC networks and get a time response.