plotting a vector field in polar coordinates

90 views (last 30 days)
I have a Field given by 3 components. < rho theta z> in cylindrical
E = p*cos(theta),P*sin(theta),z^2 I wish to plot this vector field.
How do i do this. Quiver seems to only work for rectangular. I have also seen people try to convert the field to rectangular which has not worked either. I am at a complete and total loss

Answers (2)

Star Strider
Star Strider on 14 Feb 2015
The quiver3 function can do 3D quiver plots. You have to have derivatives of your components as well, but you can calculate them easily enough once you know how you want to take the derivatives. Are ‘p’ and ‘P’ different or a typo? Are they constants or variables as well, and if so, what are they functions of?
An example of your code or an illustration of what plot result you want would help.
  5 Comments
Star Strider
Star Strider on 14 Feb 2015
Edited: Star Strider on 14 Feb 2015
E D I T Did you consider the compass plot? It may do what you want.
————————————————————————————————————————————
Previous Comment: Your 2D example worked because ‘a’ and ‘b’ were the origin points and the sin functions acted as the directional derivatives at those points (at least as far as quiver was concerned).
I didn’t say that quiver or its friends required an independent variable ‘t’ or anything else. I was implying that if your variables were functions of ‘t’ (parametric functions), the directional derivatives would have to be with respect to ‘t’, or whatever the variable was.
Regardless, the first three arguments to quiver3 are the origins of the arrows and the last three arguments are the directions the arrows go. How you choose to define them is entirely up to you. I still have absolutely no idea how you want to define the directional derivatives with respect to your ‘E’ variable, so I can’t help you with that. I also don’t know if ‘E’ are your directional derivatives, the origins of the arrows, or something else. (An easy way to get the last three arguments for quiver3 if you have vectors for the first three, is to use the gradient function.)
I’m just guessing at what you’re doing. You have to provide the details. If you code your cylindrical coordinate system and plot it with quiver3, I will have some idea. If it doesn’t work, I can probably help you get it to work. No promises.
Code would quite definitely help me understand what you’re doing.
Hassam Alhajaji
Hassam Alhajaji on 6 May 2021
@Robert None of your variables are a function of time if your field is static

Sign in to comment.


Aneesh Vasudev
Aneesh Vasudev on 10 Apr 2018
Robert, you could try to use the following code (hope it works, havn't checked it).
Use the regular quiver to plot the output of the function. For more info Wikipedia page
function [x,y,u_x,u_y]=Fieldpol2cart(r,O,u_r,u_O)
[x,y] = cart2pol(O,r);
u_x = u_r.*cos(O) - u_O.*sin(O);
u_y = u_r.*sin(O) + u_O.*cos(O);

Categories

Find more on Vector Fields in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!