Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Part 2: Solve the following problems in MATLAB 1 , i, Fill in the function E = m

ID: 2268561 • Letter: P

Question

Part 2: Solve the following problems in MATLAB 1 , i, Fill in the function E = myElin(n, Remember that an elimination matrix looks like an identity matrix with one extra entry of-? in row i and column j. 1. j ) to create an n by n elimination matrix E. 2, myMult (A) to create an n by n multiplier matrix M. Remember that a Fill in the function M multiplier matrix looks like an identity matrix with the 1's along the diagonal replaced with the inverse of the diagonal entries of A. = Fill in the function P = myPerm (n , Remember that a permutation matrix looks like an identity matrix with rows i and j swapped. 3. i, j ) to create an n by n permutation matrix P. 4, Fill in your code in the function x = my Solver (A, the algorithm outlined in class to first eliminate the entries below the diagonal (moving down and then right), then eliminate the entries above the diagonal (moving up and then left), and then using the multiplier matrix to make the diagonal entries 1. You should use your myElim, myPerm, and myMult functions inside of this function b ) to solve the equation Ax-b. Follow

Explanation / Answer

a)

function E=myElim(n,l,i,j)
E=eye(n);
E(i,j)=-l;
end


>> myElim(4,2,2,1)

ans =

1 0 0 0
-2 1 0 0
0 0 1 0
0 0 0 1

>>

b)

function E=myMult(A)
E=eye(length(A));
if (size(A)~= size(transpose(A)))
disp('error : matrix A should be square matrix');
else
for i = 1:length(A)
E(i,i)=1./A(i,i);
end
end
end

>> myMult(A)

ans =

1.0000 0 0
0 0.2000 0
0 0 0.1111

>>

c)

function E=myPerm(n,i,j)
E=eye(n);
x=E(j,1:end);
E(j,1:end)=E(i,1:end);
E(i,1:end)=x;
end

>> myPerm(4,2,1)

ans =

0 1 0 0
1 0 0 0
0 0 1 0
0 0 0 1

4)

function x=mySolver(a,b)
x=a;
end

>> b=[1;3;5];
>> mySolver(A,b)

ans =

2.8333
-4.6667
2.5000

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote