Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

NAME : Lacido, Mary Joy__________

Section: CS11S2_____________ Date: October 10, 2022

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. Determine if the given matrix A is singular. Explain your answer. (6 points)

MATLAB Syntax MATLAB Output


A= [ 1 2 0; 3 – 1 2; -2 3 -2;] A= 1 2 0

3–12

-2 3 -3

Cond(a) 12.79

Explanation: nonsingular matrix

2. Determine the solution set of the give linear system below , using the method of (6 points each)

a. Inverse of Matrix
b. Gauss-Jordan Elimination
c. LU- factorization
MATLAB Syntax MATLAB Output
Inverse of Matrix 231

A=[ 2 3 1; 3 3 1; 2 4 1] 331

B=[-1;-1;-2 241

Inv(a)*b B=

-1

Ans=

2.000

-1.000

2.000
Solution Set:
MATLAB Syntax MATLAB Output
Gauss- Jordan Elimination Ans=

A=[2 3 1; 3 3 1; 2 4 1] 1002

0 1 0 -1

B=[-1; -1; 2] 0 0 1 -2

Rref{[a b]}

Solution Set:
MATLAB Syntax MATLAB Output
LU-factorization A= 2 3 1

331
A=[2 3 1; 3 3 1; 2 4 1]
241

-1
B=[-1; -1; 2]
-1

Ans=
Lu(A)
3.000 3.000 1.000

0.6667 2.000 0.3333

0.666 0.5000 0.1667

Solution Set:

Which do you think among the three method used is appropriate in the given system? Explain your
answer in 3 to 5 sentences. ( 5 points)

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 (8 points each )

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?
Set-Up of the System of Linear MATLAB Syntax MATLAB Output
Equation
1x+1.5y= 150

2x+y= 170

X+ 1.5y= 150

2x+y=170

X=52.50
Y=65

Final Answer

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?
Set-Up of the System of Linear MATLAB Syntax MATLAB Output
Equation

Final Answer

Command History
Honor Pledge: I affirm that I have not given or received any unauthorized help on this assignment, and that this is my
own.

You might also like