三次元空間にあるベクトルから流線を表示する方法

11 views (last 30 days)
知真 梶山
知真 梶山 on 8 Jun 2023
Answered: COVAO on 2 Feb 2024
初学者です.
以下のような三次元空間上に529個の離散点(x,y,z)があり,それぞれの点に対してベクトル(u,v,w)が割り当てられています.
これらのベクトル分布から流線を表示する方法を探しています.
流線の表示には streamline 関数が用意されていると思いますが,使い方がよく分かりません.
アドバイスをお願いいたします.
可能であれば,流線の表示まで行っていただけますと幸いです.
load results
quiver3(S.x,S.y,S.z,S.u,S.v,S.w,'AutoScaleFactor',.4,'LineWidth',1) % ベクトルの分布を表示
view([90 360 40])

Answers (1)

COVAO
COVAO on 2 Feb 2024
以下は、大気の流れのベクトルと流線をプロットする例です。
quiver3, streamlineを用いています。
steamlineのドキュメントの例に基づいて作成しています。
  • meshgridで16 個の架空粒子の開始位置を定義しています。粒子はすべて x = 80 からスタートし、20 ~ 50 の範囲の開始 y 位置と 0 ~ 15 の範囲の開始 z 位置をもちます。
  • 大気の流れにおける startXstartYstartZ という一連の開始位置に置かれた架空粒子について、3-D 流線の頂点データを計算します。
% Load the wind data set which includes wind velocity components (u,v,w) and grid coordinates (x,y,z)
load wind;
% Extract a subset of the grid coordinates and wind velocity components
X = x(5:10,20:25,6:10); % Extract a subset of x-coordinates
Y = y(5:10,20:25,6:10); % Extract a subset of y-coordinates
Z = z(5:10,20:25,6:10); % Extract a subset of z-coordinate
U = u(5:10,20:25,6:10); % Extract a subset of u-component of wind velocity
V = v(5:10,20:25,6:10); % Extract a subset of v-component of wind velocity
W = w(5:10,20:25,6:10); % Extract a subset of w-component of wind velocity
% Create a 3D quiver plot to visualize the vectors
quiver3(x,y,z,u,v,w); % Plot vectors as arrows
% Define the starting points for streamlines
[startX,startY,startZ] = meshgrid(80,20:10:50,0:5:15); % Create a 3D grid of starting points
% Compute 3D streamlines from vector data
verts = stream3(x,y,z,u,v,w,startX,startY,startZ); % Compute streamlines for the vector field
lineobj = streamline(verts); % Plot the streamlines
% Set the view and axis properties for the plot
view(3); % Set the view to 3D
axis equal; % Set the aspect ratio of the plot to be equal

Products


Release

R2023a

Community Treasure Hunt

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

Start Hunting!