Effacer les filtres
Effacer les filtres

Get the nearest value when two arrays are logged at different time.with different logging rates

1 vue (au cours des 30 derniers jours)
Hi! I have two data sets one is logged at 200ms and other is logged at 1 sec. Lets call the data set logged at 1 sec as 'x' and the one logged at 200ms as 'y'. Now what is what value in x will be the closest match to the values in y.
The size of 'y' is 360313x1 and the size of 'x' is 71885x1. Please let me know if any more info will be needed. My apologies I cant share the real data set.
  2 commentaires
Jan
Jan le 12 Déc 2017
Modifié(e) : Jan le 12 Déc 2017
Does the fact, that one data set is recorded with 200ms and the other with 1s play any role in the solution? Are the values sorted?

Connectez-vous pour commenter.

Réponse acceptée

Jan
Jan le 12 Déc 2017
y = rand(360313, 1)
x = rand(71885, 1);
index = zeros(size(x));
for k = 1:numel(x)
[~, index(k)] = min(abs(y - x(k)));
end
Does this match your problem?
  2 commentaires
sc1991
sc1991 le 12 Déc 2017
Thanks a lot it works.Thanks so much for the help
sc1991
sc1991 le 14 Déc 2017
Hi! Jan I just saw an issue. So, your programs works fine but I have one sensor that measures speed and I when its trying to find the closest value it will check for any values that's closest to it. But since one is logging at 200ms and the other is logging at 1 sec and they both start at different time. I want that ones we have found the match for first index where they match it just increments and never go below that first match index. will you be able to help?

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Time Series Collections dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by