The function Fr_bin2dec.m will convert a positive Binary system Fraction to a Decimal system Fraction. The function Fr_dec2bin.m will convert a positive Decimal system Fraction to a Binary system Fraction.
MATLAB itself has bin2dec.m and dec2bin.m, but there seems to be no standard MATLAB function when fractions are involved. For eg, if we wish to quickly obtain the decimal equivalent of the binary fraction : 0.000101, or say, 0.010101111, or say, 11010.1011001 etc. (They are : 0.078125, 0.341796875 and 26.6953125 resp.)
These two dual functions were developed mainly with a view to get quick results while learning Arithmetic (Entropy) Coding in School.(Now, I have added more comments to better explain the programme to other viewers.)
The results of these two functions are limited in accuracy due to the "precision" used in the function num2str.m in addition to Floating Point limits and Rounding errors. These functions have been set to a precision of 16 in the use of num2str.m. Accumulation of errors due to these limits can be seen when the two functions are tested back-to-back in pairs.
Both these files have many "Usage Egs" which will make it easy for the reader to apply these functions and test them with more critical / unique cases of his own - including possibly with some cases which may break the code ? Pl do forward me any new case that breaks the code beyond the aforesaid limitations.