reduce density of a time series

조회 수: 11 (최근 30일)
jakobs
jakobs 2019년 11월 11일
편집: Daniel M 2019년 11월 12일
I have a time series a of a river discharge with over 700000 points. I'd like to "clean" the data and delete all irrelevant points (points which share almost the same value with their neigbouring points). I imagined a code which compares two values (e.g. a_i - a_i+1) and if the result is below a certain threshold the second value gets deleted.
I already tried functions like downsampling, but I am afraid that I will loose important information about minima and maxima. Is there maybe somewhere a link to this question?
  댓글 수: 3
jakobs
jakobs 2019년 11월 12일
Hello,
thanks for the help. The plottet result is here.
The values of the second figure range inbetween 10^10 (at the beginning) and 10^5 (shortly after).
figure.png
Daniel M
Daniel M 2019년 11월 12일
편집: Daniel M 2019년 11월 12일
Actually if you don't mind can you run it again but this time change the bottom plot to semilogy and detrend your data when you input it using detrend(X).
Also it wouldn't hurt if you could draw or otherwise indicate what you would like your output signal to look like. Is it just a smoother version of the original?
(Or I could look at your data if you uploaded).

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

답변 (1개)

Adam Danz
Adam Danz 2019년 11월 11일
편집: Adam Danz 2019년 11월 12일
" I imagined a code which compares two values (e.g. a_i - a_i+1) and if the result is below a certain threshold the second value gets deleted."
The diff() function does the first half of your description. I'll assume your dates are stored in a column vector named "dates" and they are in datetime format. If they are not in datetime format some very small modifications will need to be made.
theshold = hours(1); %can be any duration: minutes(30), hours(12) days(2), etc....
rm = [false; abs(diff(dates))<threshold]; %logical vector of datetimes to remove
datesClean = dates(~rm);
% OR
% dates(rm) = []; % to keep variable name
If you're working with a timetable, you'll apply the rm vector to the rows of the table.
  댓글 수: 2
Daniel M
Daniel M 2019년 11월 11일
This idea should work even if OP is not talking about a timeseries object, but just regular data as a function of time.
Adam Danz
Adam Danz 2019년 11월 11일
편집: Adam Danz 2019년 11월 11일
Yeah; it's been my experiences that the term "time series" is more generally used by folks in this forum to describe their data more often than describing the use of Matlab's timeseries objects. Unless they specifically indicate one or the other, I assume they are speaking more generally. Good point!

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

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by