Be careful with the first and last point of your data since it doesn't find those. You should look at the adjacent index (2 or end-1) if you want to classify them as either a peak or valley.
Like that, each value of "a" is correlated to each value of "b", but applying the formula of the correlation, the correlation of two single numbers is NaN. To compute the correlation correctly, traspose the input vectors
Best Answer