# MATLAB Questions and Answers – Default Variables

«
»

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

1. What is the output of the following code?

`q=0;syms p,q`

a) q=0
b)

```   p
q=0```

c)

```    p
q```

d) Error

Explanation: The scope of the syms command ends when the input is a comma or a semi-colon. q is already declared to 0. q is not taken input as a symbolic variable. There would’ve been an error while trying to define q after a comma but it does not occur since it was already declared as an integer variable.
Output:

```   p
q=0```

2. What is the default variable while evaluating a transfer function?
a) s
b) p
c) z
d) Any

Explanation: The MATLAB evaluates the transfer function according to the basic definition of a transfer function. So it represents a system in the frequency domain where the frequency is defined by ‘s’.

3. What is the default variable while evaluating a Laplace transform?
a) s
b) t
c) Any
d) l

Explanation: If no variable is specified within the laplace command, the function gives the laplace transform of the input function with ‘s’ as the independent variable. Hence, s is correct.

4. The output of the following code is

`laplace(exp(-3*t),p)`

a) Error due to p
b) 1/(s+3)
c) 1/(p+3)
d) Error due to t

Explanation: The input to the laplace command has to be a function which has been already declared. Hence MATLAB returns an error for this code since the t is not defined previously. It wouldn’t give an error on p.

5. The output of the following code is

`solve(‘w+z=0’)`

a) -z
b) -w
c) Error
d) No such fuction

Explanation: The default variable in MATLAB is x. Since w is nearer to x than z, the command will return a solution for w since we haven’t specified the variable who’s solution we seek. Hence, the answer is –z.

6. The default variable in case of solve(‘f(x,y,p,a,l)’) command is __________
a) x
b) Variables near to x
c) Variables away from x
d) No default variable

Explanation: Unless specified, the solve command would take x as the default variable who’s solution is being sought. If the function did not have x as an independent parameter, the default variable would’ve been variables near to x.

7. What is the default parameter for dsolve() command?
a) t
b) No default parameter
c) Input differentiating variable
d) Defined input parameter

Explanation: The dsolve command returns a solution which is parameterized by the variable that has been used as a differential in the input function. As such, there is no default variable for this command.

8. What is the default parameter for the ztrans() command?
a) z
b) w
c) s
d) no default parameter

Explanation: The default parameter for the given command is z. This is a pre-defined command in MATLAB and uses the basic definition of the Z-transform to evaluate the result.

9. What is the output of the following code?

`syms t; laplace(exp(-3*t),y)`

a) Error
b) 1/(3+s)
c) 1/(3+y)
d) 1/(3+js)

Explanation: y hasn’t been defined as symbolic. The output of the laplace transform won’t be derived since their will be an error. If we specify a desired variable, we have to declare it as symbolic before giving it as an input to our laplace command.

10. The default variable, to which the result of any computation.
a) True
b) False

Explanation: Any result is assigned to the variable ans in MATLAB. If we specify a different variable, it will be assigned to that variable.

Sanfoundry Global Education & Learning Series – MATLAB.

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