0
\$\begingroup\$

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.enter image description here

\$\endgroup\$
7
  • 3
    \$\begingroup\$ sign and gradient: 0-90 = ++; 90-180 = +-; 180-270 = --; 270-360=-+ \$\endgroup\$
    – Chu
    Nov 9, 2017 at 18:22
  • \$\begingroup\$ From \$ 180^o \$ to \$ 270^o \$ do you want to consider that as increasing (because the absolute value is) or reducing? \$\endgroup\$ Nov 9, 2017 at 18:45
  • \$\begingroup\$ 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. \$\endgroup\$
    – Mitu Raj
    Nov 9, 2017 at 18:54
  • \$\begingroup\$ @WarrenHill i want to divide the entire cycle into 4 segments, absolute value doesn't matter \$\endgroup\$
    – ruveena
    Nov 9, 2017 at 19:42
  • 1
    \$\begingroup\$ @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. \$\endgroup\$ Nov 9, 2017 at 19:55

1 Answer 1

1
\$\begingroup\$

This can be achieved by taking derivative of the sine function either in matlab code or du/dt block in simulink

grad = diff (sin(x));
if (sin(x)>0 && grad>0)  
    \\0 to 90 deg
if (sin(x)>0 && grad<0)
     \\90 to 180 deg
if (sin(x)<0 && grad<0)
      \\180 to 270 deg
if (sin(x)>0 && grad>0) 
      \\270 to 360 deg
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.