Uploaded by filloutcourseevals

EAS230 SP19 Lab3

advertisement
NAME:
LAB SECTION:
EAS 230 – Spring 2019 – Lab 3
Score: ______/40
Directions:





Make a print out of this assignment and take it with you to your lab section.
You cannot use the internet during the lab period, unless instructed by the TAs.
All problems in this lab assignment are to be performed with MATLAB with answers
written on the rubric page as directed.
Create and edit the file L03.m and upload it to UBLearns
This assignment must be submitted by the end of your lab period
Learning outcomes:
By the end of this lab, you will be able to:
1.
2.
3.
4.
Access individual elements and subarrays within an array
Modify elements in an array
Concatenate arrays
Perform basic matrix operations in MATLAB
EAS 230 – Spring 2019 – Lab 3 – Page 1
NAME:
LAB SECTION:
Part 1: Accessing, modifying and concatenating arrays (25 points)
1. (5 pts) Open and edit a script named L03.m and create the following arrays
𝐴 = [ 2 −3 1 ]
𝐵 = [2 3 −1]
𝐶 = [ 12 14 16 18 20 22 ]
𝐷 = [0.25 0.75 1.25 1.75 2.25 2.75 3.25 3.75 4.25]
1 1.5
2
𝑁 = [1.5 0.5 −0.5
−2 −2 −2
1
𝑃 = [ 40
−4𝜋
−1
20
−2𝜋
𝜋
0
0
−3
−20
2𝜋
2.5
3
3.5
−1.5 −2.5 −3.5]
−2
−2
−2
2
−1
−40 −60]
4𝜋
6𝜋
and
𝑄 = 𝑃𝑻
2. (10 pts) Edit L03.m to display the following subarrays to screen
a. the second element of 𝐴
b. the third element of 𝐵
c. the third, fourth, fifth and sixth elements of 𝐷
d. the entire third row of 𝑃
e. the entire third column of 𝑄
3. (4 pts) Edit L03.m in order to modify the following arrays accordingly.
a. Set the second row of 𝑁 to be all zeros
b. Set the lower right corner of 𝑃 to be a 2 × 2 matrix of 1’s
4. (6 pts) Edit L03.m in order to create the following new array by concatenating the
existing subarrays accordingly.
EAS 230 – Spring 2019 – Lab 3 – Page 2
NAME:
LAB SECTION:
Part 2: Investigating properties of matrix math (8 points)
1. In the MATLAB Command Window, create the following matrices, vectors, and
scalars using the following commands:
A = randi(20, 2, 3);
B = randi(20, 3, 3);
C = randi(20, 3, 3);
k1 = 3;
k2 = 2;
2. Determine if the following statements are True or False regarding matrix
operations in MATLAB using matrices A, B, and C, and scalars k1 and k2. To perform
this task, you should perform the operation on the left-hand side and the right-hand
side and compare the results. If the statement is true, write down the size of the
resulting matrix. If the statement is false, write down why it is false (i.e. why can the
operation not be performed, or the MATLAB error). Use the table on the rubric page
to write your answers in the corresponding location.
(𝒌𝟏 𝒌𝟐 )𝑨 = 𝒌𝟏 (𝒌𝟐 𝑨)
𝑨 − 𝟐𝑩 is a valid operation
𝑩𝑪 = 𝑪𝑩
𝑨𝑩 is a valid operation
Part 3: Completing and submitting your lab (2 points)
1. Save the file L03.m in the Current Folder
2. Confirm with your TA/Instructor that your m-file L03.m has been appropriately
created and contains all code required to perform this lab. Submit L03.m to
UBLearns under the Lab3 assignment (Course Information > Lab assignments >
Lab3).
EAS 230 – Spring 2019 – Lab 3 – Page 3
NAME:
LAB SECTION:
EAS 230 – Spring 2019 – Lab 3
RUBRIC
Score: ______/40
Quiz (5 pts)
Part 1: Accessing, modifying and concatenating arrays (25 points)
_________ / 5 pts
_________ /2 pts
_________ /2 pts
_________ / 2 pts
_________ / 2 pts
_________ / 2 pts
1.
2.a.
2.b.
2.c.
2.d.
2.e.
Correct MATLAB code
Correct MATLAB code
Correct MATLAB code
Correct MATLAB code
Correct MATLAB code
Correct MATLAB code
_________ / 2 pts
_________ / 2 pts
_________ / 6 pts
3.a.
3.b.
4.
Correct MATLAB code
Correct MATLAB code
Correct MATLAB code
Part 2: Investigating properties of matrix math (8 points)
POINTS
Expression
_______ / 2 pts
(𝑘1 𝑘2 )𝐴 = 𝑘1 (𝑘2 𝐴)
_______ / 2 pts
𝐴 − 2𝐵 is a valid operation
_______ / 2 pts
𝐵𝐶 = 𝐶𝐵
_______ / 2 pts
𝐴𝐵 is a valid operation
T or F
Explanation
Part 3: Completing and submitting your lab (2 points)
POINTS
_______ / 1 pt
_______ / 1 pt
DESCRIPTION
L03.m exists and is named correctly
L03.m submitted correctly to UBLearns
EAS 230 – Spring 2019 – Lab 3 – Page 4
Download