Why the function or variable A is not recognized?
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Pierre Hansel Malihan
il 26 Mag 2022
Commentato: Pierre Hansel Malihan
il 26 Mag 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 Commenti
Risposta accettata
Walter Roberson
il 26 Mag 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 Commenti
Walter Roberson
il 26 Mag 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
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Logical in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!