How to use curl for 2D-vector field correctly?

15 次查看(过去 30 天)
Hi everyone,
I've some data from a simulation like (x,y,u,v) which u corresponds to velocity in x-direction and v in y-direction. In order to compute the curl of vector V(u,v) i did it like so:
x = data(:,1);
y = data(:,2);
u = data(:,3);
v = data(:,4);
V = [u v];
R = [x y];
curl = curl(V,R);
Now i wanna to see if my code is correct or is there any mistake?
Many thanks!
  1 个评论
Andreas Passos
Andreas Passos 2021-2-25
编辑:Andreas Passos 2021-2-25
I have the exact same question,
'how to calculate the curl of a trajectory'
if you found the answer please let me know

请先登录,再进行评论。

回答(1 个)

Jess Lovering
Jess Lovering 2019-8-15
I think you might have to make those inputs into matrix format first with meshgrid. Then you can pass those directly into curl.
x = data(:,1);
y = data(:,2);
u = data(:,3);
v = data(:,4);
[X,Y] = meshgrid(x,y);
[U,V] = meshgrid(u,v);
curl = curl(X,Y,U,V);
  2 个评论
Nima
Nima 2019-8-15
If I use meshgrid, then I will receive 0 and NAN as results of curl!
Jess Lovering
Jess Lovering 2019-8-15
Sorry - you are right. I am not sure because the help says it needs to be a matrix "as if produced by meshgrid."

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Cartesian Coordinate System Conversion 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by