How to create stacked quiver plots?
5 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Bjorn Gustavsson
2022-9-2
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Vector Fields 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!