How can I convert vector fields from Cartesian to polar coordinate system in MATLAB 7.10 (R2010a)?

I have a vector (velocity) field and would like to convert it from Cartesian to polar coordinate system. I am looking for a MATLAB function that directly does the conversion.

 Risposta accettata

To convert a vector field from Cartesian to polar coordinate system, there is no MATLAB function that directly does the conversion. However, the command CART2POL can be used to convert a single set of Cartesian co-ordinates to the corresponding polar co-ordinates. As a workaround, this function can be applied manually. The following MATLAB code provides an example:
[X,Y] = meshgrid(-2:.2:2);
U = X.*exp(-X.^2 - Y.^2);
V = X.*exp(+X.^2 + Y.^2);
THETA = cart2pol(X,Y);
Ur = U .* cos(THETA) + V.* sin(THETA);
Uth = V .* cos(THETA) - U.* sin(THETA);
The above code computes radial (Ur) and azimuthal (Uth) velocity vectors from the Cartesian velocity (U and V).

Più risposte (0)

Categorie

Prodotti

Release

R2009b

Community Treasure Hunt

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

Start Hunting!

Translated by