Plotting random vectors

10 ビュー (過去 30 日間)
Jenn Lee
Jenn Lee 2011 年 10 月 21 日
Just a heads up, I have virtually no matlab experience. I need to generate a an XY-plane where a random number 'n' vectors will be plotted. How do I do this?
Also, after they are plotted I want to iterate the function so that every time I hit enter the graph will update moving the vectors in a certain manner based on the following two functions: (x_i is the i^th particle's position) x_i(t + 1) = x_i(t) + v_i(t)(t-t_0) as position
(i^th particles direction) theta(t+1) = theta(t)_r
where theta(t)_r denotes the average direction of velocities of of the particles surrounding the ith particle being within a circle of radius r.
Hopefully this would eventually make all the vectors point in the same direction and cluster to a certain area.
Thanks in advance

採用された回答

Poul Reitzel
Poul Reitzel 2011 年 10 月 21 日
R = rand(N) returns an N-by-N matrix containing pseudorandom values drawn from the standard uniform distribution on the open interval(0,1).
You could draw your vectors from R by random coordinates for every vector. For plotting consider using the file:
If you need to update the plot, put a 'hold on' command after plotting the initially generated vectors. Then update the coordinates based on the requirement you mention. In a loop I would see this simple solution working.
I hope it helps!
Best regards, Poul Reitzel
  2 件のコメント
Jenn Lee
Jenn Lee 2011 年 10 月 22 日
Oh wow! Thanks!
In the second part of your answer you mentioned that I could draw my vectors from R by making random coordinates. How would I make random coordinates for every vector though?
Jenn Lee
Jenn Lee 2011 年 10 月 22 日
If I use R = rand(n), can I use quiver() to generate vectors for the points? And would I just use plot(R) to graph the generated points of R?

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeRandom Number Generation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by