All of your x1 are the same; all of your y1 are the same; all of your x2 are the same; all of your y2 are the same.
I would suggest to you that
theta=zeros(1,N);
is not correct, that you should be using a vector of theta values from 0 to something or other. I suspect you want linspace()