How can I calculate P

조회 수: 2 (최근 30일)
Matthew Cao
Matthew Cao 2020년 2월 16일
댓글: Walter Roberson 2020년 2월 16일
Hi, below is the function where I need to solve P, but when I used the code below, it gave me the wrong P. Is there any way I can modify this?
function [L, U, P] = lu_pp(A)
n = length(A);
U = zeros(n,n);
L = zeros(n,n);
P = zeros(n,n);
for k = 1:n
U(k,k)= A(k,k);
for i = k+1:n
L(i,k) = A(i,k)./U(k,k);
U(k,i) = A(k,i);
end
for i = k+1:n
for j = k+1:n
A(i,j) = A(i,j)-L(i,k)*U(k,j);
end
end
end
P = L*U*inv(A);
end
  댓글 수: 1
Walter Roberson
Walter Roberson 2020년 2월 16일
No documentation about what the input is, or what the output is expected to be, so we as outsiders have to guess that your code defines what it is intended to do, and that therefore your code is perfect the way it is.

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

답변 (0개)

카테고리

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

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by