What I did?
For matrix multiplication, the number of columns in first matrix must be equal to the number of rows in second matrix, hence I try to satisfy the issue by changing N=500 to N=1000
t = 0:1/100:10-1/100;
xn = 5 + 2*cos(2*pi*t-pi/2) + 3*cos(2*pi*4*t);
N = 1000;