Update Function

Turn the code into an Octave function