from Arithemetic Coding by Ravi Lakkundi
Program to compress text using arithmetic coding.

bit_plus_follow(bit)
function bit_plus_follow(bit)
format long
global bits_to_follow

output_bit(bit);

while(bits_to_follow>0)
    output_bit(~bit);
    bits_to_follow=bits_to_follow-1;
end

Contact us at files@mathworks.com