matlab codes from TiffanyZhou