Upload
ibnu-hamid
View
221
Download
1
Embed Size (px)
Citation preview
8/18/2019 CHE555 Procedure Lab 3
1/4
Prepared by Madam Rabiatul Adawiyah Abdol Aziz (2016) Page 1
CHE555 NUMERICAL METHODS & OPTIMIZATION
LAB 3: LINEAR ALGEBRAIC EQUATION
Task 1: TO SOLVE MATRIC X IN MATLAB
Procedure:
(a) Define matrices A and B on the command window.(b) Then, use A\B command to find matric X.
Example:
2X 1 – X2 + 3X 3 = 5
-4X 1 – 3X 2 – 2X 3 = 8
3X 1 + X 2 – X3 =4
In Command Window:
8/18/2019 CHE555 Procedure Lab 3
2/4
Prepared by Madam Rabiatul Adawiyah Abdol Aziz (2016) Page 2
Task 2: TO SOLVE MATRIC X BY USING CRAMER’S RULE IN MATLAB
Procedure:
(a) Define matric A, determinant of X1, X2 and X3 in the m-file.
(b) Then, use Cramer’s rule equation to find matric X.(c) After that, click save and run.
Example:
2X 1 – X2 + 3X 3 = 5
-4X 1 – 3X 2 – 2X 3 = 8
3X1 + X
2 – X
3 =4
In m-file:
Answer in command window:
8/18/2019 CHE555 Procedure Lab 3
3/4
8/18/2019 CHE555 Procedure Lab 3
4/4
Prepared by Madam Rabiatul Adawiyah Abdol Aziz (2016) Page 4
Task 4: TO SOLVE MATRIC X IN EXCEL
Procedure:
(a) Define matrices A and B.
(b) To find inverse for matric A, select 3x3 box, type =minverse(select matric A). Then, clickF2 and simultaneously press (ctrl, shift and enter) button.
(c) To find matric X, select 3x1 box, type =mmult(select matric A inverse, select matric B).Then, click F2 and simultaneously press (ctrl, shift and enter) button.
Example:
2X 1 – X2 + 3X 3 = 5
-4X 1 – 3X 2 – 2X 3 = 8
3X 1 + X 2 – X3 =4
In Excel:
Task 5: EXERCISE
3X 1 – 0.1X 2 – 0.2X 3 = 7.85
0.1X 1 + 7X 2 – 0.3X 3 = -19.3
0.3X 1 – 0.2X 2 + 10X 3 = 71.4