Code to zero the elements above major diagonal
6 views (last 30 days)
Show older comments
Hi, I’m finding an inverse of a matrix using Gaussian elimination. So, the first step is that I had to carry out row operations zero the elements below the diagonal and that has no problem with me. The problem is I don’t know what code I need to write on the script to zero the elements above the major diagonal. If I could get an answer for that it would be very great. Thank you.
1 Comment
James Tursa
on 22 Oct 2018
Please post your code and then tell us what steps you are doing or output you are getting that you think needs fixing.
Answers (2)
Tiny Rick
on 22 Oct 2018
1 Comment
Steven Lord
on 22 Oct 2018
Since this is almost certainly a homework assignment, your textbook probably has some pseudocode you can adapt into a function.
If this is not a homework assignment, don't invert and/or use Gaussian elimination. Use the backslash operator \ to solve your linear system of equations, or (if you absolutely must compute the inverse) use the inv function.
See Also
Categories
Find more on Creating and Concatenating Matrices 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!