Title | Matlab Activity (System of Linear Equation) |
---|---|
Course | Linear Algebra With Matlab |
Institution | Technological Institute of the Philippines |
Pages | 7 |
File Size | 384.1 KB |
File Type | |
Total Downloads | 5 |
Total Views | 137 |
Solving system of linear equation using MATLAB...
MATLAB ACTIVITY 3 – Solving System of Linear Equation Using MATLAB A. Using MATLAB commands compute the following expressions if possible. Write the MATLAB SYNTAX you used and MATLAB out put on the space provided
1. Show that matrix A is singular 1 A= [ 3 −2
2 −1 3
0 2] −2
MATLAB SYNTAX >> A = [1 2 0; 3 -1 2; -2 3 -2] >> D = A(1,1)*[-1 2; 3 -2]-A(1,2)*[3 2; -2 -2]+A(1,3)*[3 -1; -2 3] >> Determinant = [D(1,1)*D(2,2)-D(1,2)*D(2,1)] >> A^-1 MATLAB OUTPUT
If determinant is 0, the matrix is invertible and singular. Therefore matrix A is singular.
2. Solve the given linear system using 2x + 3y + z = −1 3x + 3y + z = 1 2x + 4y + z = −2 a. Inverse of matrix MATLAB SYNTAX >> a = [2 3 1; 3 3 1; 2 4 1] >> format rat >> a^-1 MATLAB OUTPUT
b. Gaussian Elimination MATLAB SYNTAX: GAUSSIAN ELIMINATION >>[A b] >>rref ([A b]) MATLAB OUTPUT: GAUSSIAN ELIMINATION
c. LU-Factorization MATLAB SYNTAX: LU-FACTORIZATION [L U] = lu(A) y = L\b x = U\y MATLAB OUTPUT: LU-FACTORIZATION
B. For the following word problems, set up a system of linear equations then solve using matrices. Verify your answer using MATLAB. Write the MATLAB syntax and MATLAB output on the space provided 1. A mix of 1 lb almonds and 1.5 lbs cashews sells for 150.00 Php. A mix of 2 lbs almonds and 1 lb cashews sells for 170.00 Php. How much does each nut cost per pound? � + �. �� = ��� �� + ���
� =
MATLAB
SYNTAX: nuts = [1 1.5; 2 1]; price = [150; 170] MATLAB OUTPUT:
MATLAB SYNTAX: INVERSE inv(nuts)*price MATLAB OUTPUT: INVERSE
MATLAB SYNTAX: GAUSSIAN ELIMINATION rref([nuts price]) MATLAB OUTPUT: GAUSSIAN ELIMINATION
MATLAB SYNTAX: LU-FACTORIZATION [L U] = lu(nuts) y = L\price x = U \y MATLAB OUTPUT: LU-FACTORIZATION
CONCLUSION: FIRST MIX: 52.5php per pound SECOND MIX: 65php per pound
2. Maria, Rebecca and Sally are selling baked goods for their Math club. Maria sold 15 cookies, 20 brownies and 12 cupcakes and raised 2350.00 Php. Rebecca sold 22 cookies, 10 brownies and 11 cupcakes and raised 1985.00Php. Sally sold 16 cookies, 5 brownies and 8 cupcakes and raised 1330.00Php. How much did they charge for each type of baked good? 1 5 55 + 2 0 00 + 1 2 22 = 2350 2 2 22 + 1 0 00 + 1 1 11 = 1985 6 16 6 6 5 5 5 5 8 8 6 8 8 + 5+ 8= 1330 MATLAB SYNTAX: goods = [15 20 12; 22 10 11; 16 5 8]; price = [2350;1985;1330] MATLAB OUTPUT:
3.
MATLAB SYNTAX: INVERSE inv(goods)*price MATLAB OUTPUT: INVERSE
MATLAB SYNTAX: GAUSSIAN ELIMINATION rref([goods price]) MATLAB OUTPUT: GAUSSIAN ELIMINATION
MATLAB SYNTAX: LU-FACTORIZATION [L U] = lu(goods) y = L\price x = U \y MATLAB OUTPUT: LU-FACTORIZATION
CONLUSION: Maria’s charge = 30.00 php Rebecca’s charge = 50.00 php Sally’s charge = 75.00 php...