Utility functions used in MATLAB code.