I have an array consisting of temperatures from different days. My goal is to extract the elements where the temperature is either increasing or decreasing for n number of days.
Lets say we have an array consisting of following temperatures
temp=[4,5,7,8,9,7,6,7,8,6,5,4,3,2]
If we say n=3, then if for example the temperature has increased for two days in a row but then decreases on the third day we don't want to extract that information, only consider the elements where the temperature havs increased/decreased for minimum n days in a row.
Lets say n=3, then from the temp array above, the extraction would be
increasingTemp1=[4,5,7,8,9] ( i.e temp[0:5] )
increasingTemp2=[6,7,8] ( i.e temp[6:9] )
decreasingTemp1=[9,7,6] ( i.e temp[4:7] )
decreasingTemp2=[8,6,5,3,2] ( i.e temp[8:] )
is there a way of doing this?
Thanks