matlab scripts for CREM