Building up a Matrix using for LOOP and summation
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Abdulrahman Odhah
le 5 Avr 2020
Commenté : Abdulrahman Odhah
le 16 Avr 2020
Hello fellows,
I am trying to make this equation but I couldn't do the summaiton part , i tried to use the double for loop but still not sure how to do the summation part,
I have the matrix " a " already defined 4x4 also initial l and u matrices are defiend l=eye(N),u=zeros(N,N);
any hints?
0 commentaires
Réponse acceptée
David Hill
le 5 Avr 2020
I believe the below is correct.
I=eye(4);
u=zeros(4);
u(1,1:4)=a(1,1:4);
I(1:4,1)=a(1:4,1);
for i=2:4
for j=1:4
u(i,j)=a(i,j)-sum(I(i,1:i-1).*u(1:i-1,j)');
if i<j
I(j,i)=(I(j,i)-sum(I(j,1:i-1).*u(1:i-1,i)'))/u(i,i);
end
end
end
2 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Matrix Indexing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!