The code produces the correct pattern when compared to MATLAB code but the data is off in many places.