Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

how to find a window of days in a time series data with values in a range

조회 수: 1 (최근 30일)
nlm
nlm 2020년 5월 1일
마감: MATLAB Answer Bot 2021년 8월 20일
I have a time series data from which I need to find a window of days where the start value is >0.4 and end value is <0.2. However, the values in that window range between 0.4 and 0.2. I have this so far. However, my code is finding all values which have a decreasing trend for 10 days.
AA = data;
s = [0;diff(AA)];
ss = sign(s);
ss(AA<0.4)=-1;
ss= ss';
c = conv2(ss,win , 'valid');
win = ones(1,10)*-1;
p = find(conv2(ss, win, 'valid') == -1);
  댓글 수: 2
Ameer Hamza
Ameer Hamza 2020년 5월 1일
Can you share the data? I there a single window or several windows between 0.2 and 0.4?
nlm
nlm 2020년 5월 2일
Thanks Ameer for taking it up. Please find the data attached.

답변 (1개)

Ameer Hamza
Ameer Hamza 2020년 5월 2일
편집: Ameer Hamza 2020년 5월 2일
This shows the window of days in which the the value is within the specified range
data = load('data.mat');
AA = data.AA;
mask = (0.2 < AA) & (AA < 0.4);
days = find(mask); % contain the days on which the data is in range
plot(mask)
ylim([-0.2 1.2])
  댓글 수: 1
nlm
nlm 2020년 5월 4일
Thanks!
But this code also considers an increasing trend. What it selected are values which increased from 0.4 to 0.2 and then increased from 0.2 to 0.4. However, I'm looking for all the values where its only shows an decrease from 0.4 to 0.2, and it need not be monotonically decreasing, there can be some increases but it can to be below 0.4.

Community Treasure Hunt

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

Start Hunting!

Translated by