Plotting displacement field vector using quiver

6 ビュー (過去 30 日間)
Abhinav Srivastava
Abhinav Srivastava 2018 年 2 月 23 日
回答済み: Jaswanth 2024 年 10 月 17 日
I have two displacement arrays x and y. How to plot displacement field using quiver option. Following is the code which I have used. I am not sure whether the code is correct.
x1=load('DISP_X.xvg'); y1=load('DISP_Y.xvg'); [X,Y]=meshgrid(x1,y1); quiver(X,Y)
Please help me. Thanks in advance.

回答 (1 件)

Jaswanth
Jaswanth 2024 年 10 月 17 日
Hi,
To plot a displacement field using the “quiver” function in MATLAB, you need to ensure that your displacement arrays ‘x1’ and ‘y1’ are correctly structured. The “quiver” function requires two sets of data: the grid points where vectors are anchored, and the vector components in the x and y directions.
Assuming the data in your ‘. xvg’ files is correctly formatted and corresponds to the expected dimensions when loaded into MATLAB, Use “meshgrid” to create a grid where the vectors will be anchored.
% Assuming x1 and y1 are vectors. If they are matrices, skip meshgrid
[X, Y] = meshgrid(1:size(x1, 2), 1:size(y1, 1));
Now, Use the “quiver” function to plot the vectors.
% Plot the displacement field
quiver(X, Y, x1, y1);
I hope the solution provided above is helpful.

カテゴリ

Help Center および File ExchangeVector Fields についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by