# How to detect rotation in a trajectory?

3 views (last 30 days)
Struggling in MATLAB on 30 Apr 2022
Commented: Star Strider on 2 May 2022
I have to write an algorithm to detect rotation in the trajectory. Basically, I have to detect the red zone in the trajectory. Currently I have the time and coordinate data.
How do I approach it?
Struggling in MATLAB on 1 May 2022
2-D space.

Star Strider on 1 May 2022
I would use the gradient function to calculate the numerical derivative.
For example:
Plot that as a function of ‘x’ as well, and it may provide some clues on how to define that region of the curve.
.
##### 2 CommentsShow 1 older commentHide 1 older comment
Star Strider on 2 May 2022
As always, my pleasure!

### More Answers (1)

Sulaymon Eshkabilov on 1 May 2022
One way of detecting the region of values is using logical indexing, e.g.:
t = ...
x = ...
y = ...
% Way 1
Ind = t>=0 & t<=5; % Select the region according to the time data
Xs = x(Ind);
Ys = y(Ind);
% Way 2
Ind = x>=0 & x<=5; % Select the region according to x data
Xs = x(Ind);
Ys = y(Ind);
##### 1 CommentShow NoneHide None
Struggling in MATLAB on 2 May 2022
Thanks for your comment.

### Categories

Find more on Commercial & Off-Highway Vehicles in Help Center and File Exchange

R2022a

### Community Treasure Hunt

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

Start Hunting!