Page 1 of 1

*** Matlab *** I tried to run the following algorithm in matlab but I got "NaN" for some elements for some reasons, coul

Posted: Sat May 14, 2022 3:16 pm
by answerhappygod
*** Matlab ***
I tried to run the following algorithm in matlab but I got
"NaN" for some elements for some reasons, could you fix it, please?
I'll upvote if it is clear, thank you!
==================================
L = [];
U = [];
for i = 1:len
for j = 1:len
L(i,j) = 0;
U(i,j) = 0;
end
end
for i = 1:len
for j = i:len
sum = 0;
for k = 1:len
sum = sum +
L(i,k)*U(k,j);
end
U(i,j) = A(i,j) - sum;
end
for j = 1:len
if i==j
L(i,i) = 1
else
sum = 0;
for k = 1:len
sum = sum +
L(j,k)*U(k,i);
end
L(j,k) = (A(j,i) - sum) /
U(i,i)
end
end
end