Professional Documents
Culture Documents
ACT2
ACT2
ACT2
LABORATORY ACTIVITY #2
MATRICES
I. Learning Outcomes:
At the end of the laboratory activity, the students should be able to:
1. Use MATLAB in creating and manipulating matrices
2. Solve linear systems of equation using MATLAB
b. MATLAB Codes:
a. >>x=eye(5,4)
b. >> ones(6,3)
c. >> zeros(4,5)
d. >> rand(4,4)
e. >> randn(3,5)
ans =
c. Answer:
a. x =
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
0 0 0 0
b. ans =
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
c. ans =
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
d. ans =
2.
a. Problem: If A = magic (24), what is the value in row 21, column 22?
c. Answer:
3.
a. Problem: Create the matrix X = diag ([3:3:15])
c. Answer: x=
3 0 0 0 0
0 6 0 0 0
0 0 9 0 0
0 0 0 12 0
0 0 0 0 15
4.
a. Problem: Using magic square of 5, write the values in lower triangular
c. Answer: 17 0 0 0 0
23 5 0 0 0
4 6 13 0 0
10 12 19 21 0
11 18 25 2 9
5.
a. Problem: Using magic square of 4, write the values in upper triangular.
c. Answer: 16 2 3 13
0 11 10 8
0 0 6 12
0 0 0 1
6.
a. Problem: Determine the determinant of the matrix.
b. Answer: x =274
7.
a. Problem: Determine the determinant and coefficients w, x, y, z
c. Answer: x=28495
8.
a. Problem: Define the matrices below: (use shortcuts if applicable)
c. Answer:
8a= 1 2 3 4 8b= 1 1 1 1
6815 1111
9427 1111
9472 1111
8c= 8d= 8e=
16 2 3 13 1000 3 6 9 12
5 11 10 8 0300 18 24 3 15
9 7 6 12 0050 27 12 6 21
4 14 15 1 0007 27 12 21 6
9.
a. Problem: Using the matrices of #8, solve the following:
c. Answer: 9a=15 30 45 60
90 120 15 75
135 60 30 105
135 60 105 30
9c=10 4 4 4
4 148 4 4
4 4 4 4
4 4 4 4
10.
a. Problem: Using the matrices of #8, solve the following:
c. Answer: x=
1 2 3 4 2 2 2 2 4 3 3 3
6 8 1 5 2 2 2 2 3 4 3 3
9 4 2 7 2 2 2 2 3 3 3 4
9 4 7 2 2 2 2 2 4 3 3 3
1 4 7 10 16 2 3 13 1 0 0 0
16 22 1 13 5 11 10 8 0 3 0 0
25 10 4 19 9 7 6 12 0 0 5 0
25 10 19 4 4 14 15 1 0 0 0 7