This is the original matlab code published by Dianne P. O'Leary and Bert W. Rust for their 2013 paper here. It contains just one modification to make it work on GNU Octave as well as Matlab. This modification is just a package include and will not change the original logic.
This code is republished here with the permission of Professor O'Leary. Thank you.