Plotting displacement field vector using quiver

6 Ansichten (letzte 30 Tage)
Abhinav Srivastava
Abhinav Srivastava am 23 Feb. 2018
Beantwortet: Jaswanth am 17 Okt. 2024
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.

Antworten (1)

Jaswanth
Jaswanth am 17 Okt. 2024
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.

Kategorien

Mehr zu Vector Fields finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by