**
Fill This Form To Receive Instant Help**

Homework answers / question archive / CEE 384 Numerical Methods for Engineers Fall 2016 Arizona State University MATLAB Assignment #5 Please read “MATLAB Assignment Submission Guidelines” in Blackboard before submission

CEE 384 Numerical Methods for Engineers Fall 2016 Arizona State University

**MATLAB Assignment #5 **

*Please read “MATLAB Assignment Submission Guidelines” in Blackboard before submission. Not following the guidelines will result in loss of credit, even though you may have the correct answer(s). *

Write code of your own and answer the questions in this assignment.

- Submit your code through Cody Coursework for problem 1.1 and 2.1.
- Submit a report through Blackboard

Naive Gauss Elimination, Gaussian elimination with partial pivoting and LU decomposition are the basis of this assignment.

** [Hints]** Consider using

__Problem 1__

** **

Write a MATLAB function to perform LU decomposition using Naive Gauss elimination. You’ll need to employ nested loops in this assignment. Do not use the “lu” command in your code.

- It should be named
**luDecompose** - The function should have
**one**input argument: the**square**matrix ( -by- ) to be decomposed. In this assignment, assume this matrix is**nonsingular**and**no division by zero**occurs during the forward elimination of naive Gauss elimination. - The function should have
**two**output arguments stored as**an****-by-**????????????????**matrix**:- the lower triangular matrix, stored in the left submatrix; and 2) the upper triangular matrix, stored in the right submatrix.

- In each iteration of the forward elimination, the function should display on screen 1) the current iteration number; and
- the current coefficient matrix resulted from forward elimination.

- At the end of your function, display the final lower and upper triangular matrices on screen.

- Test 1: with input argument
- Test 2: with input argument
- Test 3: with magic(5)
- Test 4: with random input matrix

Page 1 of 2

CEE 384 Numerical Methods for Engineers Fall 2016 Arizona State University

School of Sustainable Engineering and The Built Environment Dr. Lou and Lawrence

Using “lu” command to decompose

into a lower- and an upper triangular matrix.

Compare the results of your code in question 1) to those of the “lu” command. Are the results different? If yes, why?

__Problem 2__

** **

Write a MATLAB function to solve linear equations. You’ll need to employ nested loops in this assignment.

- It should be named
**pivGauss** - The function should have
**one**input argument: the**augmented matrix**( -by-(???????? + 1)) representing a system of linear equations. In this assignment, assume the coefficient matrix is nonsingular. - The function should have
**two**output arguments stored as**an****-by-(**???????? + ????????**)****matrix**:- the resulting matrix from the forward elimination process using Gauss elimination with partial pivoting; and
- the solution to the system of linear equations as a
**column**vector, stored in the last column of the output matrix.

- In each iteration of the forward elimination process, the function should display on screen 1) the current iteration number;

2) the current coefficient matrix, resulted from forward elimination with partial pivoting; and 3) the current right-hand side vector, resulted from forward elimination with partial pivoting.

- At the end of the function, display your solution to the system of linear equations.

- Test 1: with input arguments
- Test 2: with random input arguments
- Test 3: with random input arguments

Using “mldivide” or “\” command, solve the system of linear equations and compare the results to those from your program.

Page 2 of 2

Already member? Sign In