Reputation: 5282
I'm calculating
info = log2(double(1/prob))
in matlab, but when I try to print the result, it show -Inf
prob
is a uint8
variable.
how can it fix it?
Upvotes: 1
Views: 181
Reputation: 3330
If you divide 1
by another integer, this will surely result in a zero.. putting this into a logarithm yields the observed -Inf... you will need to convert to floating point prior to the division, e.g.
info = log2( 1./double(prob) )
Upvotes: 4