LU decomposition

조회 수: 11 (최근 30일)
Zdenek
Zdenek 2012년 3월 11일
Hi, i´m a begginer(looser) in matlab and i don´t know, where is problem in this script. Please help me and thanks for tips.
function [L, U, P] = LURozklad(A)
P = eye(size(A));
L = P;
A_pred = A;
P_pred = P;
for k = 1:size(A) - 1
r = IPR(A, k, k);
A_pred = A;
A = VymenaRadkuMatice(A, k, r);
P_pred = VymenaRadkuMatice(P_pred, k, r);
P = P_predchozi;
for i = k + 1:size(A)
m_ik = A(i, k)/A(k, k);
for j = k + 1:size(A)
A(i, j) = A(i, j) - m_ik * A(k, j);
end
A(i, k) = m_ik;
end
printf('matice A: ', A);
for i = 2:size(A)
for j = 1:size(A)
if i > j
L(i, j) = A(i, j);
end
end
end
printf('matice L: ', L);
for i = 1:size(A)
for j = 1:size(A)
if i <= j
U(i, j) = A(i, j);
end
end
end
printf('matice U: ', U);
P = P_predchozi;
printf('matice P:', P);
end
function [r] = IndexPivotnihoRadku(A, OdRadku, IndexSloupce)
MaxHodnota = 0;
for i = OdRadku:size(A)
if abs(A(i,IndexSloupce)) > MaxHodnota
MaxHodnota = abs(A(i,IndexSloupce));
r = i;
end
end
function [A] = VymenaRadkuMatice(A, radek1, radek2)
PomocnyRadek = A(radek1,:);
A(radek1, :) = A(radek2,:);
A(radek2, :) = PomocnyRadek;
end
function printf(string, value)
disp(string);
disp(value);
end
end
end
  댓글 수: 1
Jan
Jan 2012년 3월 12일
Please explain, why you are thinking, that this function has a problem.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by