How to filter winter months
1 回表示 (過去 30 日間)
古いコメントを表示
Hi there,
I am trying to filter the winter months in my data. I use the command below:
time = time (month(time) >= 1 & month(time) <= 4 & month(time)>9 & month(time)<=12) ;
It does not work. Does anyone know the answer?
I appreciate your help.
0 件のコメント
採用された回答
その他の回答 (1 件)
Walter Roberson
2020 年 2 月 27 日
There does not exist a number that is simultaneously at most 4 but at the same time also greater than 9. & is only satisfied if all the parts are satisfied.
You want a test that checks whether something is true OR something else is true.
However I would suggest that you consider using a different method. In particular read about ismember()
Or you could have a single logical vector that you index by the month number.
I notice that the local definition of "winter" where I live is slightly different. Your code would call October a winter month. Where I live, October is not considered a winter month: it is considered an autumn month. One kind of wheat is harvested, and many pumpkins might be harvested, but the rest of the harvest is September or even August for many greens. October is just sort of in-between. Overcast and rain, temperatures fluctuating above and below freezing. November is mostly below freezing here but "winter" is not quite considered to have started here until the last week of November when we get a heavy snow.
The point is that you need to reconsider what "winter" means in context. Like only 100 miles south of us, "winter" is about a month later than for us.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Dates and Time についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!