Quantcast
Channel: MATLAB Central Newsreader Recent Posts
Viewing all articles
Browse latest Browse all 19628

Re: Verify if a matrix is upper triangular. Also if it is lower triangular

$
0
0
"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

Hi, I made this:


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?

Viewing all articles
Browse latest Browse all 19628

Trending Articles