Some useful matlab code