Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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) ||

image text in transcribedfunction [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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Security

Authors: Alfred Basta, Melissa Zgola

1st Edition

1435453905, 978-1435453906

More Books

Students also viewed these Databases questions

Question

6. Vanguard

Answered: 1 week ago