Info
此问题已关闭。 请重新打开它进行编辑或回答。
how to find a window of days in a time series data with values in a range
1 次查看(过去 30 天)
显示 更早的评论
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
2020-5-1
Can you share the data? I there a single window or several windows between 0.2 and 0.4?
回答(1 个)
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])
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/289645/image.png)
1 个评论
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!