I am developing an image processing application for object detection.
At some point I am using log of the generalized eigenvalues vector of two square covariance matrices. Assume that I have a 9x9 covariance matrix a.
a = rand(9, 9)%just generating random matrix for testing problem easily
b = eig(a, a)%generalized eigenvalues vector containing nine values equal to 1
%so we have b = [1.000, 1.000, 1.000 ... (9 times)]
c = log(b(:)) %we know b contains values of 1. and log(1) is 0.
Even though we know and can debug to see that b contains elements with value 1 and log(1) is 0, content of c is:
1.0e-014 *
0.0222
0.1110
0.0222
0.0222
-0.0777
0
0.0222
0.0888
0
This in my case. Anyone knows why doesn't c have values of 0? Thanks.
As @OliCharlesworth commented the values of b aren't really 1. I did the exact same as you did and got the following for b:
b =
1.0000
1.0000
1.0000
1.0000
1.0000
1.0000
1.0000
1.0000
1.0000
But when I opened b up in the variable explorer I got the following:
You'll see that there's only really one value of 1
and not 1.000
meaning that there are some trailing values that aren't shown in MatLab. Hence you would get the following for c:
c =
1.0e-15 *
0.2220
-0.4441
0.2220
-0.2220
0.2220
0
0.2220
-0.1110
-0.1110
Notice the 1.0e-15
that's where trailing values are being found.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With