plotting a vector field in polar coordinates
92 views (last 30 days)
Show older comments
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
0 Comments
Answers (2)
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
on 14 Feb 2015
Edited: Star Strider
on 14 Feb 2015
————————————————————————————————————————————
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
on 6 May 2021
@Robert None of your variables are a function of time if your field is static
Aneesh Vasudev
on 10 Apr 2018
Robert, you could try to use the following code (hope it works, havn't checked it).
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);
0 Comments
See Also
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!