フィルターのクリア

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.
  2 件のコメント
Jan
Jan 2017 年 12 月 12 日
編集済み: Jan 2017 年 12 月 12 日
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?
sc1991
sc1991 2017 年 12 月 12 日
Yes the data set is sorted.

サインインしてコメントする。

採用された回答

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 月 12 日
Thanks a lot it works.Thanks so much for the help
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 Center および File ExchangeTime Series Collections についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by