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 = 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 upStep 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