LU decomposition

5 ビュー (過去 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 Center および File ExchangeInteractive Control and Callbacks についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by