Finding breakpoints for a given 2D Points and their associated time stamps

Hi,
I have the following data:
A set of 2D Points and their recorded time stamps.
(x1,y1) ; t1
(x2,y2);t2
(xn,y2); tn
I would like to find the break points for this trajectory.
BreakPoint: Point,where the direction is completely deviating.
I would be really glad if someone can propose some good appach for finding the points,marked as red in the images attached.
I tried the following methods:
1) Checking the slope of the line,(like,wherever the slope is changing, mark it as a breakpoint.But since,they are just rough lines (and not exact lines),user may not draw all the points exactly on the same line.
2) Here,I am also making use of the time stamps.Using distance approach i.e. plotting graph between time and distance(of consecutive points) and wherever the distance value is approximately zero, mark it as a breakpoint.But,since the value is not exactly zero,I am unable to find the correct threshold.
Please suggest some better algorithms to achieve this.
Thanks in advance.

2 commentaires

can you provide a sample of your data?
Hi Stephan,
I am attaching two text files for your reference.(These are supposed to be a triangle and rectangle).
In the text file..x and y data are seperated by a "comma".

Connectez-vous pour commenter.

 Réponse acceptée

Stephan
Stephan le 14 Jan 2019
Modifié(e) : Stephan le 15 Jan 2019
Hi,
see the attached findEdges function:
function [px, py] = findEdges(x,y,t,treshold)
dx = diff(x);
dy = diff(y);
ds = (dx.^2+dy.^2).^0.5;
dt = diff(t);
v = ds./dt;
id = find(v<treshold);
px = x(id);
py = y(id);
end
It takes the coordinates and the time as seperate vectors and calculates the velocity. If the velocity is lower then the treshold that you enter, the point is marked as an edge and is given back as a result from this function. Save it in your Matlab project path and use it this way:
%% Triangle
% Prepare data
pos = importdata('C:\Jung\Matlab\Projekte\Triangle_Unscaled.txt');
t1 = importdata('Triangle_TimeStamp.txt');
t1(end)=[]; % Data for time of triangle is 1 entry longer than x,y data
x1 = pos(:,1);
y1 = pos(:,2);
clear pos
% Find the edges
[result_x1, result_y1] = findEdges(x1,y1,t1,0.01);
% Plot data
figure(1)
plot(x1,y1)
hold on
% Plot the edges
scatter(result_x1, result_y1,'or')
hold off
Result is:
Same for the rectangle:
%% Rectangle
% Prepare data
pos = importdata('C:\Jung\Matlab\Projekte\Rectangle_Unscaled.txt');
t2 = importdata('Rectangle_TimeStamp.txt');
t2(end)=[]; % Data for time of rectangle is also 1 entry longer than x,y data
x2 = pos(:,1);
y2 = pos(:,2);
clear pos
% Find the edges
[result_x2, result_y2] = findEdges(x2,y2,t2,0.01);
% Plot data
figure(2)
plot(x2,y2)
hold on
% Plot the edges
scatter(result_x2, result_y2,'or')
hold off
with result:
Finding a good treshold value will give you more or less points as edge.
Best regards
Stephan

6 commentaires

Math Enthusiast
Math Enthusiast le 15 Jan 2019
Modifié(e) : Math Enthusiast le 15 Jan 2019
Hi Stephan,
I just tried the code.I am getting the result like,in the attached image.
As seen,I am getting many extra points.
Can you please let me know of some other procedure.Can we make use of time stamps too and interpret something? Something like velocity analysis or acceleration analysis?
Please help!
in your unscaled data you attached, there are no time stamps.
the code i provided worked a bit better on the unscaled data (less additional points). Please try.
i will think about, how to improve this.
can you think about either providing the data that you want to use or finding the needed points on the raw data?
Hi Stephan,
Here,I am attaching 4 files...including timestamp data and x,y coordinates data for 2 trajectories.
I would be glad,if you can provide some other good approach,which does not produce too many break points
See my edited answer
@Stephan: Thanks a lot! I will try with all the sample data ,I have and try to find some reasonable threshold. I will update you again,in case of some issues.Thanks again!
If this was useful for you please accept my answer.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Environment and Settings dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by