Clear Filters
Clear Filters

unable to perform tracking

2 views (last 30 days)
Chris Ron de
Chris Ron de on 29 May 2020
Commented: Chris Ron de on 12 Jun 2020
I am pretty new with MATLAB and I want to link datapoints of different tracks to each other. I do have a file with data that I can change into x, y and z coordinates within a while1-loop. What I wanted to do is comparing each new set of datapoints with the already existing datapoints to see if they can be seen as a next point in an existing track. If that is not possible, the new datapoints are the start of a new track.
I tried to do it with vectors and structs, but no luck so far. The initial dataset is attached to this question and I am wondering if there is someone who can help me out in taking the right steps to a solution.
What I do have so far is:
clear variables;
f = fopen('','r');
%The current state of each track is in a matrix, showing the last value
A = zeros(6,4);
x_plot = []; % make vector for storing x-values
y_plot = []; % make vector for storing y-values
z_plot = []; % make vector for storing z-values
time = []; % make vector for storing time values
heading = []; % make vector for storing heading values
elevation = []; % make vector for storing elevation values
distance = []; % make vector for storing distance values
speed = []; % make vector for storing speed values
acc = []; % make vector for storing acceleration values
i_values = []; % make vector for storing i-values
while 1
%Read line
line = fgetl(f);
if ~ ischar(line), break, end
row = str2num(line);
t = row(1);
h = row(2);
e = row(3);
d = row(4);
r = cosd(e) * d;
x = sind(h) * r;
y = cosd(h) * r;
z = sind(e) * d;
if A(1,1)==0
for i=1:size(A,1)
if difference > 150

Answers (1)

Gaurav Garg
Gaurav Garg on 8 Jun 2020
Hey Chris
You would want to run 2 loops -
  1. Iterating over all the datapoints,
  2. Running over the datapoints assigned to tracks already
Here on, i would assume each new track being represented with a new row and each column representing the datapoints on the track.
While iterating over each datapoint, you can check whether this datapoint -
  1. should be make a new track, or
  2. should be a part of an existing track.
In case, the datapoint should make a new track, you can add a new row to your matrix, representing a new track.
If it comes to be a point on an existing track, you can add this datapoint to a new column in the respective row/track.
Gaurav Garg
Gaurav Garg on 12 Jun 2020
Hey Chris,
'If I understood it right, another if statement is necessary within the while1-loop, or can this also be done by adding an elseif statement?' ==> Which loop are you talking about? Because the first loop is used only to iterate over the datapoints on the track, and second one would be used to check the datapoint already assigned (matrix in your case), and no assignment would be needed in the first loop (because you are checking for the right tracks and the respective checkpoints in the second loop).
'Is there a more elegant way to solve this problem' ==> What you are doing here is quite elegant in its own way. You can try other ways as well, which would work , however they would still give you the same performance (time-wise).
Chris Ron de
Chris Ron de on 12 Jun 2020
Hi Gaurav,
I think you hit the right button. I was thinking that it all could be done with one if statement and I was wondering why the while loop and the if statement are not working together. I am going to introduce another if statement and I think I have to make it with true and false statements of the first loop. At this moment it is just a thought and I have to figure it out because I'm not that familiar with MATLAB. Thanks anyway so far and if you have an idea about coding that true and false story, it is more than welcome.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!