How to create stacked quiver plots?

조회 수: 7 (최근 30일)
doruk isik
doruk isik 2022년 9월 1일
댓글: Bjorn Gustavsson 2022년 9월 2일
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!

채택된 답변

Bjorn Gustavsson
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
doruk isik
doruk isik 2022년 9월 2일
I wasn't sure how to use quiver3 as the structure looks like quiver3(X,Y,Z,U,V,W) and I only am intrested in Y,Z and V,W arguments. But never thought of manipulating X and U components as you suggested.
I changed lines 0*slices_all(:,6,ix),.. and slices_all(:,6,ix),... to get what I initially wanted.
hold on
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),...
slices_all(:,3,ix),...
0*slices_all(:,6,ix),...
slices_all(:,5,ix),...
slices_all(:,6,ix),...
'k');
end
view(3)
I really appreciate the help, thank you!!
Bjorn Gustavsson
Bjorn Gustavsson 2022년 9월 2일
My pleasure, and great that it helped!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Vector Fields에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by