Finding and plotting radial component in vector field

조회 수: 6 (최근 30일)
djr
djr 2019년 7월 7일
댓글: djr 2019년 7월 9일
Hello Everyone,
I have a vector filed given on a Cartesian grid with two vector components Uc and Vc (attached). My grind has 14 rows (-1:0.25:2.25) and 14 columns (-1.5:0.25:1:75). The attached figure is that vector field plotted in the following way:
% dx = dy = 0.25 km (grid spacing)
dx = 0.25; dy = dx;
nc = 14; nr = 14;
% Create grid
[x,y] = meshgrid(0:dx:(nc-1)*dx,0:dy:(nr-1)*dy);
% Plot vectors (rows and colomns need to be switched due to indexig)
subplot(1,2,1)
quiver(x,y,flipud(Uc),flipud(-Vc), 'Color','k','LineWidth',1);
I have to do this flipud and -Vc in order to get the match with the published version of that figure. I am reconstrcuting a figure from one paper. My main problem is the following. From x = y = 0 point (center), I need to:
  1. Obtain the radial comonent of vector (radially outwards or inwards) in each grid point from Vc and Uc;
  2. Plot these radial components, so I have a tyical polar graph where the arrous are diviring (or converging) away (or towards) the center. However, the length of these arrows needs to be the radial component of the vector field as described in 1.
Thank in advance,
djr

채택된 답변

David Goodmanson
David Goodmanson 2019년 7월 9일
Hi djr,
nc = 14; nr = 14;
% Create grid
[x,y] = meshgrid(0:dx:(nc-1)*dx,0:dy:(nr-1)*dy);
% Plot vectors (rows and colomns need to be switched due to indexig)
U = flipud(Uc);
V = flipud(-Vc);
figure(1)
quiver(x,y,U,V, 'Color','k','LineWidth',1);
grid on
% -----------
absr = sqrt(x.^2+y.^2); % |r|
rx = x./absr; % vector components of the radial unit vector
ry = y./absr;
rcomp = (U.*rx + V.*ry); % the radial component of (U,V)
Wx = rcomp.*rx;
Wy = rcomp.*ry;
figure(2)
quiver(x,y,Wx,Wy); % the result
grid on
figure(3);
contour(x,y,rcomp) % take a look at the value of the radial component
grid on
colorbar

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by