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

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

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

Post 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
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply