Question: function [x,flag] = linearSolve(A,b) [nra,nca] = size(A); [nrb,ncb] = size(b); flag = 1; % assume success until something bad happens! if (nra ~= nca) ||

function [x,flag] = linearSolve(A,b) [nra,nca] = size(A); [nrb,ncb] = size(b); flag =function [x,flag] = linearSolve(A,b) [nra,nca] = size(A); [nrb,ncb] = size(b); flag = 1; % assume success until something bad happens! if (nra ~= nca) || (nra ~= nrb) || (ncb > 1) warning('linearSolve requires an n x n matrix A and column vector b of dim n. Empty Solution returned.'); x= [ ]; flag=0; else n = nra; % set dimension to simple variable of n A = [A, b]; % concanenate end % % % PUT Gaussian Elimination Loops HERE % % % % % After Gauss Elim is Over, Do Back Subs b = A(:,n+1); % extract b from the augmented matrix A (: ,n+1) =[ ]; % This isn't neccessary, by I will delete the last column of A (that held b!) x = b; % initialize x (this is techinally a loop!) for row = n:(-1):1 for col = (row+1):n x(row) = x(row) - A(row,col)*x(col); end x(row)=x(row)/A(row,row); % divided by pivot value end

end

Option 1: Complete the function linear Solve.m in Matlab Necessary Features (Get the right answer! 9pts) Implements Gaussian Elimination with Partial Pivoting If Gaussian Elimination is successful, the solution will be bound with Back Substitution (I have written this part for you!) If Gaussian is unsuccessful (some pivot column has no nonzero pivots available), then the Gaussian Elimination loop is broken and the empty solution x=[ ] is returned and the exit flag is set to O Additional Features (1 pt) Inner Loop reordering for potential speed up Option 1: Complete the function linear Solve.m in Matlab Necessary Features (Get the right answer! 9pts) Implements Gaussian Elimination with Partial Pivoting If Gaussian Elimination is successful, the solution will be bound with Back Substitution (I have written this part for you!) If Gaussian is unsuccessful (some pivot column has no nonzero pivots available), then the Gaussian Elimination loop is broken and the empty solution x=[ ] is returned and the exit flag is set to O Additional Features (1 pt) Inner Loop reordering for potential speed up

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!