% flipbit.m % flips bit i in a binary string in a vector inv % % inv = input vector % i = position to change bit parity of function r = flipbit (inv, i) r = inv; foo = size(r); n = foo(2); % this is the "width" of the input vector if i > n error('the specified index is larger than the size of the vector') elseif r(i) == 0 r(i) = 1; elseif r(i) == 1 r(i) = 0; end