Combining Functions of Gaussian elimination and Banded Matrix

8 ビュー (過去 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 Center および File ExchangeDescriptive Statistics についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by