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
On 11/24/2012 6:04 PM, Edwardo wrote:
> "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.
...

> function res = isupper(A)
> res = isequal(A,triu(A)); ...

...[lower elided for brevity]...

> this is ok right?

That's identically the logic I used except for isequal() instead of
all() and ==

Nicer form, actually to eliminate the nested ALL's...

--

Viewing all articles
Browse latest Browse all 19628

Trending Articles