Your NEG is some weird array that is a row vector (a "linear index") of the vector of indexes where E is negative, followed by a row vector of the actual E values themselves. Why are the indexes there? You don't want to find peaks based on the index numbers , which, actually will be monotonically increasing so there won't be any peaks even if it did make sense. Secondly, since NEG is a row vector, the second column of it, which you pass into findpeaks() will be just a single number, which is the number of the second index where your signal goes negative. It doesn't make sense. With findpeaks() you can find both peaks and valleys. I suggest you read up on findpeaks and look at Star's example.