필터 지우기
필터 지우기

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?

댓글을 달려면 로그인하십시오.

채택된 답변

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에서 Time Series Collections에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by