# Detect the maximum of signal

I am trying to create a bloc with Xilinx system generator to detect the maximum of a sine wave. I used the strategy that:

$$x(n-1)-x(n-2)>0$$

and

$$x(n)-x(n-1)<0$$

but I didn't find the maximum. The result is wrong, as shown in the image below:

What am I doing wrong? How can I detect the signal maximum?

• Can you scale your graph so that it's clear when the digital signal is high and when its low? – The Photon Feb 9 '15 at 17:33
• How fast are you sampling and what is the frequency of the sine? – Eugene Sh. Feb 9 '15 at 17:43