Hello, I have a matrix of values of size 8760 x 6 (a small excerpt is shown below), in which 1st column is the year, 2nd month, 3rd is the day, 4th is the hour, 5th is value 1 and 6th is value 2. The nature of graph for val 1 and val 2 is sinusoidal, hence there is alternate peaks and troughs. I need to identify the peaks in val 1 and corresponding peaks in val 2 within +/- 3 hr window and then difference between the two values. For example, in the matrix below, the 1st peak value is 2.08 in val 1 and next value is +1 hr next to it, i.e., 1.75 in val 2. In the next positive cycle, the peak value is 2.02 and corresponding peak value in val2 is 1.82 and so on.
Year Mo Day hr val 1 val 22014 1 1 0 1.84 1.672014 1 1 1 1.74 1.562014 1 1 2 1.26 1.042014 1 1 3 0.47 0.232014 1 1 4 -0.4 -0.652014 1 1 5 -1.11 -1.402014 1 1 6 -1.43 -1.782014 1 1 7 -1.30 -1.682014 1 1 8 -0.76 -1.122014 1 1 9 0.078 -0.272014 1 1 10 0.89 0.582014 1 1 11 1.62 1.292014 1 1 12 2.08 1.742014 1 1 13 2.06 1.752014 1 1 14 1.61 1.332014 1 1 15 0.87 0.562014 1 1 16 -0.05 -0.372014 1 1 17 -0.87 -1.252014 1 1 18 -1.47 -1.862014 1 1 19 -1.59 -2.002014 1 1 20 -1.28 -1.632014 1 1 21 -0.56 -0.872014 1 1 22 0.327 0.0222014 1 1 23 1.181 0.852014 1 2 0 1.85 1.5212014 1 2 1 2.020 1.8192014 1 2 2 1.736 1.6372014 1 2 3 1.074 1.0212014 1 2 4 0.142 0.1152014 1 2 5 -0.81 -0.832014 1 2 6 -1.54 -1.582014 1 2 7 -1.82 -1.902014 1 2 8 -1.59 -1.682014 1 2 9 -0.92 -0.982014 1 2 10 0.002 -0.0582014 1 2 11 0.892 0.8252014 1 2 12 1.693 1.5292014 1 2 13 2.138 1.9142014 1 2 14 2.057 1.8292014 1 2 15 1.547 1.2872014 1 2 16 0.696 0.4018
Finally, the desired output is:
2014 1 1 2.08 1.76 0.322014 1 2 2.02 1.82 0.202014 1 2 2.14 1.91 0.22
Any help?
Best Answer