# How to create stacked quiver plots?

8 views (last 30 days)
doruk isik on 1 Sep 2022
Hello,
I have a dataset with 6 columns corresponding to slices taken at different x-locations (see below)
The dataset is created as (x_coordinate,y_coordinate,z_coordinate,Vel_x, Vel_y, Vel_z) where Vel_x, Vel_y and Vel_z are x,y and z velocities, respectively.
Based on the x-coordinates, I created individual arrays at each x-location named slice1, slice2, slice3 etc. where each array has a similar structure with the first column of all being constant values (corresponding fixed x-locations).
I would like to create a quiver plot at each x-location to see the velocity arrows in Y-Z plane (refer to image).
I am able to create quiver plots seperately using
xlabel('y')
ylabel('z')
axis equal
which produces
I was wondering how I could add a third axis which will be the x-axis and have quiver plots in one single figure to see the change of velocity vectors in Y-Z plane along the x-direction.
How can I place my quiver plots with an offset, is there a setting or an object property that controls the let's say x-offset?
Thanks!

Bjorn Gustavsson on 2 Sep 2022
This sounds like a straight use of quiver3? Either
h1=quiver3(slice2(:,1),...
slice2(:,2),...
slice2(:,3),...
'k');
Or just put the calls into a loop:
dx_offset = 1;
n_slices = 5;
slices_all = cat(3,slice1,slice2,slice3,slice4,slice5); % Since I just realised the "2"
for ix = n_slices:-1:1
h1(ix) = quiver3(dx_offset*(ix-1)+0*slices_all(:,2,ix),...
slices_all(:,2,ix),...
slice_all(:,3,ix),...
'k');
end
HTH
##### 2 CommentsShowHide 1 older comment
Bjorn Gustavsson on 2 Sep 2022
My pleasure, and great that it helped!

### Categories

Find more on Vector Fields in Help Center and File Exchange

R2019a

### Community Treasure Hunt

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

Start Hunting!

Translated by