Why the function or variable A is not recognized?
1 view (last 30 days)
Show older comments
Pierre Hansel Malihan
on 26 May 2022
Commented: Pierre Hansel Malihan
on 26 May 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 Comments
Accepted Answer
Walter Roberson
on 26 May 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 Comments
Walter Roberson
on 26 May 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
More Answers (0)
See Also
Categories
Find more on Characters and Strings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!