In your code, there are a few crucial errs, i.e.:
(1) no need to introduce a new variable range that creates conflict with matlab's built in fcn range().
(2) why to use the same variable with different index orders: xpk(k,:) vs. xpk(:,k), xsk(k,:) vs. xsk(:,k), etc.
(3) range-xpk does not work because range has 10 elements and xpk has different number of elements. To avoid this problem, you should use: xpk=xi + vi*dt; xsk=r_raw(k)-xpk;
(4) If you want to get xpred only, there is no need to have indexes for other variables.
(5) fr and gi are not specified.