I want to calculate mean trajectory using Dynamic Time Warping.
19 次查看(过去 30 天)
显示 更早的评论
x-axis is number of data point an y-axis is longitude.
I want to mean line from aligned singal. but it only returns dist 45.812772.
how can i use this number to calculate mean line?
and trajectory data concist of longitude, latitude.
In this example, I used only longitude data.
how to use both data while using DTW to get mean trajecotory?
2 个评论
Walter Roberson
2022-8-28
What is the difference between this and https://www.mathworks.com/matlabcentral/answers/1789165-how-to-use-dynamic-time-warping-dtw-to-multiple-trajectories?s_tid=srchtitle ?
回答(1 个)
Balavignesh
2023-10-5
Hi Sierra,
As per my understanding, you would like to plot mean trajectory using Dynamic Time Warping (DTW).
I assume that you have data points of trajectories consisting of latitude and longitude values.
I would suggest you to create an empty matrix 'distance' to store pairwise distances between all trajectories. You could iterate over all pairs of trajectories and compute their 'DTW' distance based on the latitude and longitude coordinates using the 'dtw' function and store in the 'distance' matrix.
% for i = 1:N
% for j = i+1:N
% dist(i, j) = dtw([lat(:, i), lon(:, i)], [lat(:, j), lon(:, j)]);
You could then compute the mean trajectory by finding the trajectory with the minimum average distance to all other trajectories by calculating the mean of each row in the 'distance' matrix and fincing the index of minimum mean distance.
Kindly have a look at the following documentation links to have more information on:
- 'dtw' function: https://www.mathworks.com/help/signal/ref/dtw.html
- 'find' function: https://in.mathworks.com/help/matlab/ref/find.html
Hope that helps!
Balavignesh.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 AI for Signals 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!