From: Tamas on
hi,

I am using this line to test some properties of a matrix:

(all((eig(COV_MARTIX)) >= 0))

but this expression get evaluated false because matlab returns -0.000 for some of the eigenvalues. is that a way around that?

thanks a lot
From: Tamas on
sorry, my mistake. even if it dispalyed -0.0000 is in fact not a zero...
From: Husam Aldahiyat on
"Tamas " <t.jambor(a)ucl.ac.uk> wrote in message <hhakvg$5ei$1(a)fred.mathworks.com>...
> sorry, my mistake. even if it dispalyed -0.0000 is in fact not a zero...

format short g
From: Dave Berger on
"Tamas " <t.jambor(a)ucl.ac.uk> wrote in message <hhakek$1rr$1(a)fred.mathworks.com>...
> hi,
>
> I am using this line to test some properties of a matrix:
>
> (all((eig(COV_MARTIX)) >= 0))
>
> but this expression get evaluated false because matlab returns -0.000 for some of the eigenvalues. is that a way around that?
>
> thanks a lot

Tamas,

Check out the 'eps' function. Your -0.000 is probably not a hard 0, but just below zero. The formatting doesn't have enough precision. You could try changing your formatting to "format long eng".

-Dave
From: John D'Errico on
"Tamas " <t.jambor(a)ucl.ac.uk> wrote in message <hhakek$1rr$1(a)fred.mathworks.com>...
> hi,
>
> I am using this line to test some properties of a matrix:
>
> (all((eig(COV_MARTIX)) >= 0))
>
> but this expression get evaluated false because matlab returns -0.000 for some of the eigenvalues. is that a way around that?
>

It returns false because some of the eigenvalues are
negative (as they are computed.) Just because the
formatting shows the numbers as -0.000, they are
still negative numbers.

So what do you want to get around? The matrix is
apparently not positive definite, at least not to
within a reasonable tolerance. It is possible (even
likely) that the matrix is actually non-negative
definite, but one or more of the eigenvalues ends
up negative due to numerical slop.

John
 |  Next  |  Last
Pages: 1 2
Prev: rgb2ycbcr
Next: rgb2hsv functions mathmatical formula