How to plot a velocity field

38 visualizaciones (últimos 30 días)
Andres Benoit
Andres Benoit el 21 de Dic. de 2020
Respondida: Divyajyoti Nayak el 11 de Sept. de 2024
I want to plot a velocity field defined in polar coodinates as Vr = -10/r and Vt=10/r (radial and tangent coordinates, respectively), but im having some troubles, below the code that i made.
x = -4:0.3:4;
y = x;
[X, Y] = meshgrid(x,y);
Vr = -10./sqrt(X.^2 + Y.^2);
Vt = 10./sqrt(X.^2 + Y.^2);
quiver(x, y, Vr,Vt)
How can i plot it correctly?

Respuestas (1)

Divyajyoti Nayak
Divyajyoti Nayak el 11 de Sept. de 2024
Hi Andres,
I see that you are trying to plot a velocity field defined in polar coordinates using the ‘quiver’ function. The ‘quiver’ function however requires the velocity to be defined in cartesian coordinates. Here’s a documentation link for the ‘quiver’ function:
To plot the velocity field, convert the velocity components from polar coordinates to cartesian coordinates. Here’s a sample code that might help:
clear
clc
x = linspace(-4,4,27);
y = x;
[X, Y] = meshgrid(x,y);
r = sqrt(X.^2 + Y.^2); % r in function of (x, y)
theta = atan2(Y,X); % theta in function of (x, y)
Vr = -10./r;
Vt = 10./r;
u = Vt.*sin(theta) + Vr .* cos(theta);
v = Vt.*cos(theta) - Vr.*sin(theta);
figure
quiver(X, Y, u,v)

Categorías

Más información sobre Vector Fields en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by