Need help getting the points to move separately.

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.

2 件のコメント

KALYAN ACHARJYA
KALYAN ACHARJYA 2018 年 5 月 6 日
編集済み: KALYAN ACHARJYA 2018 年 5 月 6 日
Are you talking these points? Small case x,y,z?
Devon Romine
Devon Romine 2018 年 5 月 6 日
Yes, if you run the program with the for statement commented out, the 20 points will be in randomized positions, but as you can see with the for statement they condense down and I do not know how to fix that.

サインインしてコメントする。

 採用された回答

KALYAN ACHARJYA
KALYAN ACHARJYA 2018 年 5 月 6 日

1 投票

% 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

2 件のコメント

Devon Romine
Devon Romine 2018 年 5 月 6 日
Thank you that helped alot, will this run through all 20 time steps?
KALYAN ACHARJYA
KALYAN ACHARJYA 2018 年 5 月 6 日
You can more do that, by keep r, theta, phi in the loop. All having a random function, so it within the loop, gives different points

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by