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?

advertisement
q=0;syms p,q

a) q=0
b)

   p
   q=0
advertisement
advertisement

c)

    p
    q

d) Error
View Answer

Answer: b
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
advertisement

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

Answer: a
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
View Answer

Answer: a
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.
advertisement

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
View Answer

Answer: d
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.
advertisement

5. The output of the following code is

solve(‘w+z=0)

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

Answer: a
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
View Answer

Answer: a
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
View Answer

Answer: c
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
View Answer

Answer: a
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)
View Answer

Answer: a
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
View Answer

Answer: a
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.

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