add chopformat.m with test

Signed-off-by: Mark Histed <mhisted@gmail.com>