I don't know whether i have misunderstood or not, but some of the important codes are wrong.
In the line 51 of file kalman.m, x(i,:) = (xp + K*([cc(i),cr(i)]' - H*xp))', you just predicte the current position with the current real position and plot them in the same time.
That's why you get such a perfect result.
And I take a reference to other version of Kalman code like this one.
Just change it to the following code:
x(i+1,:) = (xp + K*([cc(i),cr(i)]' - H*xp))';
Correct me if i'm wrong.