Function File: unaryenc (value)
This function encodes the decimal value. Useful if you are trying to perform golomb-rice coding value needs to be a number or row-vector. value is a non-negative number.
Unary encoding of a +ve number N is done as follows, use N-ones followed by one zero. For instance, the unary coded value of 5 will be then (111110) in base2 which is 31x2 = 62. From this definition, decoding follows.
message = [5 4 4 1 1 1] coded = unaryenc(message) ⇒ [62 30 30 2 2 2] unarydec(coded) ⇒ [5 4 4 1 1 1]