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

1 次查看(过去 30 天)
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.

采纳的回答

Jan
Jan 2017-12-12
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 个评论
sc1991
sc1991 2017-12-14
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?

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by