As I understand the book is wrong (Notes On Digital Signal Processing by C. Britton Rorabaugh). If I replace the N by (N1) in the denumerator of the formulation which is 5+.5*cos(2*pi*n/(N1)), the results coincide exactly with that of MATLAB.
Thank you for the link.
