Question: function x = gauss ( A , B ) % The sizes of matrices A , B are supposed to be NA x NA and
function x gaussAB
The sizes of matrices AB are supposed to be NA x NA and NA x NB
This function solves Ax B by Gauss elimination algorithm.
NA sizeA; NBNB sizeB;
if NB ~ NA errorA and B must have compatible dimensions'; end
N NA NB; AB A:NA:NA B:NA:NB; Augmented matrix
epss epsonesNA;
for k :NA
Scaled Partial Pivoting at ABkk by Eq
akxkx maxabsABk:NAk
maxabsABk:NAk :NA epss:NA k ;
if akx eps, errorSingular matrix and No unique solution'; end
mx k kx ;
if kx Row change if necessary
tmprow ABkk:N;
ABkk:N ABmxk:N;
ABmxk:N tmprow;
end
Gauss forward elimination
ABkk :N ABkk:NABkk;
ABkk; make each diagonal element one
for m k : NA
ABmk:N ABmk:N ABmkABkk:N; Eq
ABmk;
end
end
backward substitution for a uppertriangular matrix eqation
having all the diagonal elements equal to one
xNA: ABNANA:N;
for m NA: :
xm: ABmNA :NABmm :NAxm :NA:; Eq
end
modify this MATLAB code to solve Gaus Jordan
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
