How to create stacked quiver plots?
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
doruk isik
le 1 Sep 2022
Commenté : Bjorn Gustavsson
le 2 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
velRad_mag=sqrt(slice2(:,5).^2+slice2(:,6).^2);
h1=quiver(slice2(:,2),slice2(:,3),slice2(:,5)./velRad_mag,slice2(:,6)./velRad_mag,'k');
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!
0 commentaires
Réponse acceptée
Bjorn Gustavsson
le 2 Sep 2022
This sounds like a straight use of quiver3? Either
h1=quiver3(slice2(:,1),...
slice2(:,2),...
slice2(:,3),...
slice2(:,5)/velRad_mag,...
slice2(:,6)./velRad_mag,...
0*slice2(:,6)./velRad_mag,...
'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),...
slice_all(:,5,ix)./velRad_mag,...
slices_all(:,6,ix)./velRad_mag,...
0*slices_all(:,6,ix)./velRad_mag,...
'k');
end
HTH
2 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Vector Fields dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!