Matlab Exam Practice Problems

advertisement
ELEC 206 Matlab Practice Questions
Chapter
Questions
1
Sample problems 1-1, 1-2, 1-4
Problem 15 a, b
Sample problems 2-1, 2-2, 2-3,
Problems 1, 2, 3, 12, 17
Sample problems 3-1, 3-4
Problems 1, 3, 7a, 18
Sample problem 4-3
Problem 6
Sample problem 5-1
7, 9, 15
Sample problems 6-1, 6-2
Problem 15, 19
Sample problems 7-1, 7-2, 7-3
Problem 1, 2
Sample problems 8-1, 8-2
Problem 1
Sample problems 9-1, 9-2
Problems 1, 6
Sample problem 10-2
2
3
4
5
6
7
8
9
10
1. True/False (circle your choice):
a. T F The final step of the Engineering Problem-Solving Methodology is
algorithm development.
b. T F The semicolon (;) suppresses output when used with MATLAB
commands.
c. T F The transpose operator (T) interchanges the rows and columns of a
matrix.
d. T F The disp command pauses a MATLAB program and prompts the user
for input.
2. Which MATLAB command generates a two-dimensional representation of a threedimensional surface?
a.
mesh(z)
c.
pie(x)
b.
contour(z)
d.
figure(n)
3. Which MATLAB command generates 100 uniform random numbers
between -5 and +5?
a.
10*rand(100)-5
c.
10*randn(100,1)-5
b.
10*rand(100,1)-5
d.
5*randn(100)-10
4. Write the MATLAB commands to define the following matrices.
a.
1 3 5
G

 2 4 6
b.
F  0.0 0.2 0.4 ... 99.6 99.8 100.0
5. Show the results generated by the following MATLAB command.
y = [2.1 3.8; 8.5 5.1; 4.7 9.2];
maxy = max(y)
6. Given the following table of line and color options, write the MATLAB command to
generate a plot for x vs y1 as a dotted green line and x vs y2 as a dashed red line.
Line Type
dotted
dashed
Indicator
:
--
Color
green
red
Indicator
g
r
7. Which MATLAB command generates the solution to the system of equations AX=B?
a.
X = A/B
c.
X = sum(A.*B)
b.
X = inv(A)*B
d.
X = B*A'
8. Given the following matrices, show the results generated by these MATLAB
command A.*I
I = eye(2)
A = [1 2; 2 3]
.
9. Given the following matrix, show the results generated by these MATLAB
commands.
v = [3.7 2.4 0.3 5.2 4.8]
a.
h = find(v>3.5)
b.
high = v(h)
10. Given the following matrix, show the results generated by the MATLAB command.
R = [1.22 3.78 2.41]
fprintf('R = %3.1f \n', R)
11. Write a MATLAB function that accepts time t as an input and returns a voltage
corresponding to the following equation: v = e-tsin(5t).
12. Write a MATLAB program to prompt the user for a time constant τ and a max time
T, then generate a plot of v = e-t/τ.
13. Write the MATLAB commands to generate a table of conversions from inches to
centimeters. The range of inches should be from 0 to 36 in increments of 3.
14. Write a complete C++ program similar to that required by Exam 1.
Download