I came across a code in Matlab on how to generate the data with autocorrelation "X=cumsum(rand(n,p)-r)", where n is the number of observations, p is the number of variables and r is the correlation coefficient. The results I am getting used to be a structured patterned when plotted on scatter plot or control chart (MEWMA), the value of autocorrelation (rk) used to be very close to 1(0.9998). That is not what I want.