Filter löschen
Filter löschen

Interindividual distance from trajectories

1 Ansicht (letzte 30 Tage)
Ishani Mukherjee
Ishani Mukherjee am 12 Okt. 2022
Kommentiert: Ishani Mukherjee am 12 Okt. 2022
At a given time frame, i have trajectories of 6 points having 6 X and 6 Y cordinates. I wish to calculate the distance between these points. Therefore, I will be obtaining 15 inter-point distances at a given frame. I wish to do so for n frames. Next, I would like to find the mean distance at a particular frame. How should I go about these? thank you in advance.
My data is in the form of text files (X and Y coordinates are in separate files- as attached).
Ishani
Edit: 15 inter-point distances, not 5 as pointed out by Chunru
  2 Kommentare
Chunru
Chunru am 12 Okt. 2022
For 6 points having 6 X and 6 Y cordinates, you will have 5*6/2=15 paired distances.
doc pdist2
Ishani Mukherjee
Ishani Mukherjee am 12 Okt. 2022
Thank you for your pointing this out. Yes, at a given time I will have 15 distances.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Chunru
Chunru am 12 Okt. 2022
Bearbeitet: Chunru am 12 Okt. 2022
% xy = randn(6,2);
x = readmatrix("https://www.mathworks.com/matlabcentral/answers/uploaded_files/1153563/X_fragment1.txt");
y = readmatrix("https://www.mathworks.com/matlabcentral/answers/uploaded_files/1153573/Y_fragment1.txt");
whos
Name Size Bytes Class Attributes cmdout 1x33 66 char x 138x6 6624 double y 138x6 6624 double
nframes = size(x, 1);
dmean=zeros(nframes, 1);
for i=1:nframes
xy = [x(i,:)', y(i, :)'];
d = pdist2(xy, xy);
% extract the lower triangle
[ii, jj] = meshgrid(1:6, 1:6);
d1 = d(ii>jj); % d21, d31, ..., d61, d32, .., d62, ... d65
dmean(i) = mean(d1);
end
plot(1:nframes, dmean)
xlabel('frame number');
ylabel('mean distance')
  5 Kommentare
Chunru
Chunru am 12 Okt. 2022
See the update for one group of data
Ishani Mukherjee
Ishani Mukherjee am 12 Okt. 2022
It's working, thank you so much,

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Text Analytics Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by