Question
Sorry for the double post. I posted under the wrong subject earlier... Below is the full assignment but I only need help with getting the
Sorry for the double post. I posted under the wrong subject earlier...
Below is the full assignment but I only need help with getting the matrix into reduced echelon form using MATLAB. I know the calculations, but I can't get matlab to produce the correct matrix.
In this exercise, you will create the three types of elementary matrices, analyze their properties, and perform elementary row-operations on matrices by using the elementary matrices. (a) **Write three functions in MATLAB function E1=ele1 (n,r,i,j) function E2=ele2 (n,i,j) function E3=ele3 (n,j,k) Each of the functions creates one of the types of elementary n x n matrices E1, E2, or E3. You should start with the identity matrix eye(n). Matrix E1 is obtained from eye(n) by replacing (row j) with [(row j) + (row i)r]. Matrix E2 is obtained from the matrix eye(n) by interchanging rows i and j. Matrix E3 is obtained from eye(n) by multiplying row j by k. (ij n , 1: = )
**Type the functions in your diary file: ele1 ele2 ele3
You might also need a function that converts the numbers that are close to 0 to a zero.
**Create the following functions in MATLAB: function B=closetozeroroundoff(A) [m,n]=size(A); for i=1:m for j=1:n 2 if abs(A(i,j))<10^(-7) A(i,j) = 0; end end end B=A; and
**Type the functions closetozeroroundoff in your diary file.
**Use format compact format rat in your diary file.
**Type the matrix A=[2 1 3; 1 0 2; 2 3 1] in your diary file. Determine manually step-by-step the sequence of elementary row operations that should be performed on the matrix A in order to put it into the reduced echelon form. Then, for each step that you have identified manually,
**create a matching function E1, or E2, or E3 that performs the required operation. For example, the first possible operation will be interchanging rows 1 and 2 in A to have number 1 in a pivot position. This operations is performed by left multiplying matrix A by E2=ele2(3,1,2) (here: n=2, i=1,j=2). Calculate E2 first. Then, obtain an intermediate matrix A1, in which rows 1 and 2 of A are switched, as follows: A1=E2*A.
This is where I'm lost. I have all of the necessary functions, but nothing I put into MATLAB gives me a correct matrix.... **Continuing this way, you will be creating elementary matrices E1, E2, or E3, and a sequence of A1, A2, A3, , AN of intermediate matrices, until you arrive at the reduced echelon form of A. It will be the matrix An obtained after N steps. Note: you may need to use the function closetozeroroundoff to have a zero in a place of * in some of the intermediate matrices in the sequence A1, A2, , AN.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started