old code from matlab and octave