MATLAB Answers

Finding and plotting radial component in vector field

21 views (last 30 days)
djr
djr on 7 Jul 2019
Commented: djr on 9 Jul 2019
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

  0 Comments

Sign in to comment.

Accepted Answer

David Goodmanson
David Goodmanson on 9 Jul 2019
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

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by