added helper MATLAB function