MATLAB script for CREM