Matlab code used in lectures