Hello Amadeus, I tried to solve your problem in the following way :
1) Convert the dataset in a table;
2) Find all the points of the trajectory of the same particle;
3) Scale all the points of the trajectory ( I assumed the the starting point of the trajectory of a certain particle was the first value recorded of the particle dataset under consideration i don't know if it is a correct assumption but you can easily change it in the code);
4) Plot the scaled values of the trajectory.
% Import the data
testdata = readtable("C:\Users\Client\Downloads\testdata.xlsx", opts, "UseExcel", false)
Clear temporary variables
clear opts
% Count unique values in "PARTICLE_ID" column
n = unique(testdata.PARTICLE_ID)
ParticleNumber = numel(n)
% Plot each scaled trajectory
for i = 1:ParticleNumber
table = testdata(testdata.PARTICLE_ID == i,:); % Isolate single particle trajetory
color = {'k' 'r' 'b' 'g' 'c'};
xmin = table.X(1); % Zero point on x-axis
ymin = table.Y(1); % Zero point on y-axis
table.Scaled_x = table.X-xmin; % Scaled values on x-axis
table.Scaled_y = table.Y-ymin; % Scaled values on y-axis
plot(table.Scaled_x, table.Scaled_y, color{i})
xlabel('x')
ylabel('y')
legend
hold on
end
In the attached file "untitled.1.png" you can find the plot that was generated by this code.
I really hope it helps. Kind regards,
PGP
1 Comment
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/662098-how-to-plot-particle-trajectories-and-normalise-to-0-0-origin#comment_1160543
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/662098-how-to-plot-particle-trajectories-and-normalise-to-0-0-origin#comment_1160543
Sign in to comment.