How can I plot diagrams for a particle model?

2 ビュー (過去 30 日間)
Jeff Lau
Jeff Lau 2019 年 3 月 1 日
回答済み: Karan Singh 2025 年 1 月 6 日
I am working on a particle model that models a swarm (which involves systems of differential equations) and would like to produce diagrams of this form:
pastedImage.png
(source: Yao-li Chuang, Maria R. D’Orsogna, Daniel Marthaler, Andrea L. Bertozzi, and Lincoln S. Chayes, State Transitions and the Continuum Limit for a 2D Interacting, Self-Propelled Particle System)
Is it possible to create diagrams like this?
Right now I have
V = sym('V', [N d]); % velocity (N particles, dimension = 2), V(i,j) is the jth velocity component of the ith particle
X = sym('X',[N d]); % the position defined same way as above
I am aiming to approximate the solution numerically and plot the graphs above.
  1 件のコメント
KSSV
KSSV 2020 年 10 月 23 日
If you the locations (x,y) and the respective vector components (u,v) you can very much plot the shown figures using quiver.

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

回答 (1 件)

Karan Singh
Karan Singh 2025 年 1 月 6 日
I tried quiver as mentioned by KSSV
N = 20;
theta = linspace(0, 2*pi, N);
r = linspace(0, 1, N);
[R, T] = meshgrid(r, theta);
X1 = R .* cos(T)
X2 = R .* sin(T);
V1_radial = X1;
V2_radial = X2;
V1_rotational = -X2;
V2_rotational = X1;
figure;
subplot(1, 2, 1);
quiver(X1, X2, V1_radial, V2_radial, 'b');
axis equal;
xlabel('X');
ylabel('Y');
title('Radial Velocity Field');
grid on;
subplot(1, 2, 2);
quiver(X1, X2, V1_rotational, V2_rotational, 'b');
axis equal;
xlabel('X');
ylabel('Y');
title('Rotational Velocity Field');
grid on;

カテゴリ

Help Center および File ExchangeData Import and Analysis についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by