Question: Using matlab Write the function mySolve.m to solve nxn systems function x = foward(A,B) n = length(B); x(1,1) = B(1)/A(1,1); for i = 2:n x(i,1)

Using matlab Write the function mySolve.m to solve nxn systems

Using matlab Write the function mySolve.m to solve nxn systems function x

function x = foward(A,B) n = length(B); x(1,1) = B(1)/A(1,1); for i = 2:n x(i,1) = (B(i) - A(i,1:i-1)*x(1:i-1,1))./A(i,i); end end

function x = backward(A,B) x = zeros(n,1); x(n) = B(n)/A(n,n); for i = 3:-1:1 x(i) = (B(i) - A(i,i + 1:i + 1)*x(i + 1:i +1))/A(i,i); end end

%MYLU The function in this m-file computes an LU factorization %of an nxn matrix under the assumption that elimination can be %performed without row exchanges. %Input: nxn matrix A. %Output:lower triangular matrix L and upper triangular matrix U.

function [L,U] = MYLU(A) n = length(A); L = eye(n); U = A;

for j=1:1:n-1 for i = j +1:1:n L(i,j) = U(i,j)/U(j,j); U(i,j:n) = U(i,j:n) - L(i,j)*U(j,j:n); end end end

Submit your m-files and a diary showing how you tested the code. Submit the m-files for forward, backward, and mySolve, but not MYLU ve n x n lower triangular systems and a write a function forward. m to sol func- tion backward. m to solve n n upper triangular systems. Then write a function mySolve.m to solve n n systems (under the assumption that elimination can be performed without row exchanges). Use MYLU.m from last week's assignment. Test your code on Ax = b with 1-5 -4-9 5 9 -4 -3 04 0 A=1-8-3-9-3-2 8 -8 -6 9 5 -1 0-3 Note: If you do not have a working MYLU.m, you can get the solution from our shared Dropbox folder. I will post it after the late assignment deadline

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!