MATLAB Answers

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

33 views (last 30 days)
Nima
Nima on 15 Aug 2019
Commented: Jess Lovering on 15 Aug 2019
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!

  0 Comments

Sign in to comment.

Answers (1)

Jess Lovering
Jess Lovering on 15 Aug 2019
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 Comments

Nima
Nima on 15 Aug 2019
If I use meshgrid, then I will receive 0 and NAN as results of curl!
Jess Lovering
Jess Lovering on 15 Aug 2019
Sorry - you are right. I am not sure because the help says it needs to be a matrix "as if produced by meshgrid."

Sign in to comment.

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by