Some Matlab helper functions.