Code to zero the elements above major diagonal
이전 댓글 표시
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
James Tursa
2018년 10월 22일
Please post your code and then tell us what steps you are doing or output you are getting that you think needs fixing.
답변 (2개)
madhan ravi
2018년 10월 22일
Example:
A = ones(4)
B = tril(A)
Or
B= tril(A,1)
댓글 수: 3
madhan ravi
2018년 10월 22일
편집: madhan ravi
2018년 10월 22일
The above answer makes the upper triangular matrix zero
Tiny Rick
2018년 10월 22일
madhan ravi
2018년 10월 22일
you mean rref? example of your output is there in my answer?
Tiny Rick
2018년 10월 22일
0 개 추천
댓글 수: 1
Steven Lord
2018년 10월 22일
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.
카테고리
도움말 센터 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!