Clear Filters
Clear Filters

Compute the curl of a trajectory (identify clockwise or anti-clockwise motion)

4 views (last 30 days)
Hi everyone,
I want to calculate the curl from single trajectories.
Basically, I want to identify if the trajectory rotates clockwise of anti-clock wise and measure the rotation speed.
I use something like the below:
x = data(:,1);
y = data(:,2);
u = data(:,3);
v = data(:,4);
V = [u v];
R = [x y];
curlRes = curl(V,R);
The result is 0 everywhere.
I also tried [curlz,cav] = curl(x,y,u,v) and it gives the follwoing error
'Index in position 1 is invalid. Array indices must be positive integers or logical values.'
the vectors u,v contain negative values as they indicate the direction of the velocity
Thank you

Answers (1)

Tejas
Tejas on 24 May 2024
Hello Andreas,
It looks like you are curious about why there is an issue when trying to use the curl function and how to correctly do it.
According to the documentation, the syntax used in the initial call to the curl function is not recognized, which likely led to receiving 0 as a result due to the misinterpretation of input data arguments.
The issue with the second call to the curl function might stem from x and y being single-dimensional arrays. For the curl function to work as intended, x and y should define a grid of points on the 2D plane, with u and v specifying the vector field components at each point on this grid.
Below is a simple example from the documentation illustrating the correct approach:
[x,y] = meshgrid(-4:4,-4:4);
Fx = -y*2;
Fy = x*2;
quiver(x,y,Fx,Fy)
[curlz,cav] = curl(x,y,Fx,Fy)
On successfully applying the curl function to the input data, the result's positive sign will denote anti-clockwise rotation, whereas a negative sign will indicate clockwise rotation.
For additional insights on the curl function, consult the following documentation:

Categories

Find more on Linear Algebra 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!