MATLAB: Need help getting the points to move separately.

functiongaussianvelocity

Attached are a script and a function file. For the script if I run it before doing the steps it'll have 20 points in different places, but after I put in the velocities they all converge, any idea on how to get each point to move separately. I need all of the velocities to be rand which is why I created a function to do a random velocity based on gaussian distribution.

Best Answer

% Do this one, insert x, y, z, within for loop
% Modification
for i=1:20
x=r.*sin(theta).*cos(phi);
y=r.*sin(theta).*sin(phi);
z=r.*cos(theta);
x(i+1)=x(i)+velocities_fun(x)*dt;
y(i+1)=y(i)+velocities_fun(y)*dt;
z(i+1)=y(i)+velocities_fun(z)*dt;
end