plotting a vector field in polar coordinates

95 visualizaciones (últimos 30 días)
Robert
Robert el 14 de Feb. de 2015
Comentada: Hassam Alhajaji el 6 de Mayo de 2021
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

Respuestas (2)

Star Strider
Star Strider el 14 de Feb. de 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 comentarios
Star Strider
Star Strider el 14 de Feb. de 2015
Editada: Star Strider el 14 de Feb. de 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 el 6 de Mayo de 2021
@Robert None of your variables are a function of time if your field is static

Iniciar sesión para comentar.


Aneesh Vasudev
Aneesh Vasudev el 10 de Abr. de 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);

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