Maybe you can provide detailed formulas for the encode and decode functions, as per the example file the calculations are not consistent with the actual run.

Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!