Replaced Octave only code with Matlab versions