# Half of half cycle of sine wave

How can I identify the increasing and decreasing side of half cycle of sine wave using MATLAB code (.m file). For example the flag should set 1 if the amplitude of sine wave is increasing from 0 deg to 90 deg and should set 0 when amplitude is decreasing from 90 deg to 180 deg. • sign and gradient: 0-90 = ++; 90-180 = +-; 180-270 = --; 270-360=-+
– Chu
Nov 9, 2017 at 18:22
• From $180^o$ to $270^o$ do you want to consider that as increasing (because the absolute value is) or reducing? Nov 9, 2017 at 18:45
• well, talking in terms of logic - In the interval 0-90 , if the absolute value of (current value - previous value >=0) then flag should be 1. Otherwise 0. Nov 9, 2017 at 18:54
• @WarrenHill i want to divide the entire cycle into 4 segments, absolute value doesn't matter Nov 9, 2017 at 19:42
• @ruveena This cannot be done as a memoryless system, since there are two possible solutions for any given value. The best you can do by sampling a single point is to determine if you're in the positive or negative half-cycle. Nov 9, 2017 at 19:55

grad = diff (sin(x));