Matlab codes for studying