so Psun is a vector. You then define
so R is a vector.
Then when you have
dp(2) = -G * Msun * R / (sum(R.*R)^(3/2));
because you have that vector R on the right hand side, before the division, your result is going to be a vector. You are using /, the mrdivide operator, but (sum(R.*R)^(3/2)) is a scalar so R / (sum(R.*R)^(3/2)) is the same size as the vector R. So your overall expression is a vector, and you are trying to store that vector in the single location dp(2)