GM(1,n) matlab code