Chapter 15 Engineering Fundamentals:
An Introduction to Engineering
1. The part of the screen where you enter variables and issue MATLAB commands is known as
the
a. menu bar.
b. current folder.
c. command window.
d. command history window.
2. You can transfer old commands from the Command History Window to the Command
Window.
a. True
b. False
3. To clear the contents of the Command Window, type:
a. clear
b. clr
c. clc
d. shift-c
4. If you define x = 2/3, and then type format long, how will the value of x be displayed?
a. x = 0.66666666666666666666667
b. x = 0.66666666666667
Engineering Fundamentals, 5th ed. Chapter 15
Saeed Moaveni
c. x = 0.67000000000000
d. x = 2/3
5. If you define x = 2/3, and then type format short, how will the value of x be displayed?
a. x = 0.66666666667
b. x = 0.6667
c. x = 0.67
d. x = 2/3
Analysis:
6. If you define x = 2/3, and then type format rat, how will the value of x be displayed?
a. x = 0.66666666667
b. x = 0.6667
c. x = 0.67
d. x = 2/3
Analysis:
7. If you define x = 2/3, and then type format bank, how will the value of x be displayed?
Engineering Fundamentals, 5th ed. Chapter 15
Saeed Moaveni
a. x = 0.66666666667
b. x = 0.6667
c. x = 0.67
d. x = 2/3
Analysis:
8. To generate the set of x even numbers in the range of two to ten, what should you enter in the
Command Window?
a. x = 2;2;10
b. x = 2:2:10
c. x = 2:10:2
d, x = 2,10,2
Analysis:
9. Suppose you have defined x = [1,2,3] and y = [2,4,6] in the Command Window. Determine
the result of the following MATLAB operation: >>x + y
a. ans = 3 6 9
b. ans = 1 2 3 2 4 6
c. ans = 6 12
d. ans = 18
Analysis:
10. Suppose you have defined x = [1,2,3] and y = [2,4,6] in the Command Window. Determine
the result of the following MATLAB operation: >>x .* y
a. ans = 3 6 9
b. ans = 2 8 18
b. ans = 1 2 3 2 4 6
c. ans = 6 12
Analysis:
11. An M-file is used when you write a program that is more than a few lines long.
a. True
b. False
12. Which of the following commands are commonly used while plotting in MATLAB?
a. plot
b. title
c. grid
d. all of the above
Analysis:
13. What is the MATLAB command for calculating standard deviation?
Engineering Fundamentals, 5th ed. Chapter 15
Saeed Moaveni
a. standard
b. stddev
c. std_dev
d. std
Analysis:
14. What is the MATLAB command for calculating the square root of a number?
a. square_root
b. sqrt
c. sqr
d. sq_rt
Analysis:
15. What does the following MATLAB function do? log2(x)
a. returns the value of base-2 logarithm of x.
b. returns the value of base-10 logarithm of 2 and assigns it to x.
c. returns the value of common log of 2x.
d. returns the value of natural logarithm of 2 and assigns it to x.
Analysis:
16. Which of the following MATLAB commands would calculate the value of ex?
a. e^x
b. exp(x)
c. exp^x
d. exponent(x)
Analysis: