Why the function or variable A is not recognized?
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Pierre Hansel Malihan
le 26 Mai 2022
Commenté : Pierre Hansel Malihan
le 26 Mai 2022
function [L, U] = lu_nopivot (A)
n = size(A, 1);
L = eye(n);
for k = 1 : n
L(k + 1 : n, k) = A(k + 1 : n, k) / A(k, k);
for l = k + 1 : n
A(l, :) = A(l, :) - L(l, k) * A(k, :);
end
end
U = A;
end

0 commentaires
Réponse acceptée
Walter Roberson
le 26 Mai 2022
You have not defined A in the base workspace, so it does not exist for you to be able to pass its value into the function.
3 commentaires
Walter Roberson
le 26 Mai 2022
Example:
A = magic(11)
[Lout, Uout] = lu_nopivot(A)
A2 = randi([-9 9], 11, 11)
[Lout2, Uout2] = lu_nopivot(A2)
function [L, U] = lu_nopivot (A)
n = size(A, 1);
L = eye(n);
for k = 1 : n
L(k + 1 : n, k) = A(k + 1 : n, k) / A(k, k);
for l = k + 1 : n
A(l, :) = A(l, :) - L(l, k) * A(k, :);
end
end
U = A;
end
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!