Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Verify if a matrix is upper triangular. Also if it is lower triangular
Replies: 4   Last Post: Nov 24, 2012 7:58 PM

 Messages: [ Previous | Next ]
 Edwardo Posts: 7 Registered: 11/24/12
Re: Verify if a matrix is upper triangular. Also if it is lower triangular
Posted: Nov 24, 2012 7:04 PM

"Roger Stafford" wrote in message <k8ra04\$pab\$1@newscl01ah.mathworks.com>...
> "Edwardo " <edwardo.rivera@upr.edu> wrote in message <k8r8qj\$ljq\$1@newscl01ah.mathworks.com>...
> > ..... I want to test if a matrix is upper or lower triangular.
> - - - - - - - -
> Let A be a square matrix. It is upper triangular if
>
> all(all(tril(A,-1)==0))
>
> is true.
>
> Roger Stafford

function res = isupper(A)
res = isequal(A,triu(A)); # verify if A is equal to the upper triangular matrix A. store the result in res.
end

function res = islower(A)
res = isequal(A,tril(A));# verify if A is equal to the lower triangular matrix A. store the result in res.
end

this is ok right?

Date Subject Author
11/24/12 Edwardo
11/24/12 Roger Stafford
11/24/12 Edwardo
11/24/12 dpb
11/24/12 dpb