How can I calculate P

2 visualizaciones (últimos 30 días)
Matthew Cao
Matthew Cao el 16 de Feb. de 2020
Comentada: Walter Roberson el 16 de Feb. de 2020
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 comentario
Walter Roberson
Walter Roberson el 16 de Feb. de 2020
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.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Aerodynamics en Help Center y File Exchange.

Etiquetas

Aún no se han introducido etiquetas.

Community Treasure Hunt

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

Start Hunting!

Translated by