Combining Functions of Gaussian elimination and Banded Matrix

조회 수: 2 (최근 30일)
Hmm!
Hmm! 2021년 2월 8일
편집: Hmm! 2021년 2월 8일
Goal: to create a banded version of Gaussian elimination without pivoting.
%%Work so far: I have a code that generates a banded matrix. . .
function [Z]=bandmatrix(n,k1,k2)
Z=zeros(n,n);
for i=1:n
for j=1:n
Z(i,j)=1;
end
end
for i=1:n
for j=1:n
if (j<i-k1) Z(i,j)=0;
end
if(j>i+k2) Z(i,j)=0;
end
end
end
%% I have a code for GE without pivoting as. . .
function [x] = GE_WithoutPivoting1(A,b)
n = length(b);
for k=1:n-1
if abs(A(k,k)) < 1e-15
error('A has diagonal entries of zero')
end
for i=k+1:n
m = -A(i,k)/A(k,k); % multiplier for current row i
for j=k+1:n
A(i,j) = A(i,j) + m*A(k,j);
end
b(i) = b(i) + m*b(k);
end
end
x = GE_BackSubstitution(A,b);
QUESTION: to achieve my goal as in above, i.e., to properly implement a banded version of Gaussian elimination without pivoting. What I did was to call the GE elimination at end of the function [Z]=bandmatrix(n,k1,k2) i.e.,
function [Z]=bandmatrix(n,k1,k2)
....
....
x = GE_BackSubstitution(A,b); %This is already in my working directory
But my fear is that function [Z]=bandmatrix(n,k1,k2) might not be working and that it is function [x] = GE_WithoutPivoting1(A,b) that is working (since it is already saved on my working directory).
Please, using my two functions how do I implement a banded version of GE without pivoting. Any edition to my written codes will be welcome. Thank you

답변 (0개)

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by