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 CenterFile Exchange에서 Vector Fields에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by