Info
此问题已关闭。 请重新打开它进行编辑或回答。
Briain teaser - Filtering for particular algorithm
1 次查看(过去 30 天)
显示 更早的评论
I have a 1 second dataset of 86400 wind speed (WS) values and need assistance in filtering it. It requires a certain level of cleverness.
If the average WS exceeds:
- 25m/s in a 600s time interval
- 28m/s in a 30s time interval
- 30m/s in a 3 s time interval
If any of these parameters are met, the WS is deemed 'invalid' until the average WS remains below 22m/s in a 300 s time interval.
Here is what I have for the 600 second requirement. I do a 600 and 300 second moving average on the data contained in 'dataset'. I filter the intervals from the first appearance of an average 25m/s to the next appearance of a value below 22m/s as 'NaN'. After filtering, I will do another 600 second average, and the intervals with values flagged with a NaN will be left a NaN.
i.e.
Rolling600avg(:,1) = tsmovavg(dataset(:,2), 's', 600, 1);
Rolling300avg(:,1) = tsmovavg(dataset(:,2), 's', 300, 1);
a = find(Rolling600avg(:,2)>25)
b = find(Rolling300avg(:,2)<22)
dataset(a:b(a:find(b==1)),2)==NaN; %?? Not sure
This is going to require a clever use of 'find' and some indexing. Could someone help me out? The 28m/s and 30m/s filters will follow the same method.
0 个评论
回答(1 个)
Walter Roberson
2012-11-26
T = cumsum(dataset(:,2));
Rolling600avg = (T(601:end) - T(1:end-600)) ./ 600;
Rolling300avg = (T(301:end) - T(1:end-300)) ./ 300;
Rolling3avg = (T(4:end) - T(1:end-3)) ./ 3;
valid = true(1, size(dataset,1));
valid(601:end) = Rolling600avg < 25;
valid(301:end) = valid(301:end) & (Rolling300avg < 38);
valid(4:end) = valid(4:end) & (Rolling3avg < 30);
dataset(~valid) = NaN;
6 个评论
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!