Why the function or variable A is not recognized?
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Pierre Hansel Malihan
am 26 Mai 2022
Kommentiert: Pierre Hansel Malihan
am 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 Kommentare
Akzeptierte Antwort
Walter Roberson
am 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 Kommentare
Walter Roberson
am 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
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!