Comparing 2 Data sets (with different lenght)

4 visualizzazioni (ultimi 30 giorni)
Eliran Farhi
Eliran Farhi il 17 Gen 2021
Commentato: Eliran Farhi il 21 Gen 2021
Hey,
I have 2 data sets which values that represent a path:
One contains a theoretical values of {x,y} coordinates, and includes a lot of points to get an accurate path.
The other set includes real time measure of the coordinates, as was recorded with sensors.
The length of the two vectors can be different.
I need to compare those two paths and get a metric which indicates how close was the measure path to the actual path.
Is there any build-in function in MATLAB to do it?

Risposte (1)

Walter Roberson
Walter Roberson il 18 Gen 2021
No. The problem is not well defined.
What could make the problem well defined is if there were time measurements associated with each point, theoretical and measured. In such a case you could do
min_theory_t = min(theory_t);
max_theory_t = max(theory_t);
min_actual_t = min(actual_t);
max_actual_t = min(actual_t);
mask_theory = min_actual_t <= theory_t & theory_t <= max_actual_t;
mask_actual = min_theory_t <= actual_t & actual_t <= max_theory_t;
used_theory_t = theory_t(mask_theory);
used_actual_t = actual_t(mask_actual);
used_t = unique([used_theory_t(:); used_actual_t(:)]);
theory_x_interp = interp1(theory_t, theory_x, used_t);
theory_y_interp = interp1(theory_t, theory_y, used_t);
actual_x_interp = interp1(actual_t, actual_x, used_t);
actual_y_interp = interp1(actual_t, actual_y, used_t);
At this point, theory_x_interp and theory_y_interp and actual_x_interp and actual_y_interp are all on the same time scales, and corresponding elements talk about the predicted and actual locations. And given that, you can
how_close_path_was = sqrt(sum((theory_x_interp - actual_x_interp).^2 + (theory_y_interp - actual_y_interp).^2));
This will be a scalar.
  1 Commento
Eliran Farhi
Eliran Farhi il 21 Gen 2021
what if the framerate is the same, but movement follows the excat line, but a little bit slower?

Accedi per commentare.

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by