help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sine wave code


From: Andreas Weber
Subject: Re: Sine wave code
Date: Tue, 29 Dec 2020 16:43:55 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0

Am 29.12.20 um 16:32 schrieb Blaz:
Sure

u(k) and ipp(k) are the values that need to be cut if u(k) is above the
Cutoff value. This code cuts the sine wave but only until the sine value is
higher than the Cutoff value. I would like to prolong this until the next
zero crossing, but Im missing something.

------------------------------------------------------------------------
for k=1:1:n
        
   uac(k)=(ip(k)/CT)*(Rct+Rb);
   u(k)=uac(k)*kdc*krem;
   if (k > 1) && (ip(k)*ip(k-1) < 0)     %zero crossings
     zx = 1;
   else
    zx = 0;
   end

   if abs(u(k)) <  Cutoff
     ipp(k) = ip(k);
   elseif u(k) > 0
     ipp(k) = Ippmax;
   elseif u(k) < 0
     ipp(k) = -Ippmax;
   end
if u(k) > 0 % cutoff Value check
     u(k) = Cutoff;
   end
   if u(k) < 0
     u(k) = -Cutoff;
   end
if ipp(k) == 0 % zero crossing
     j = 0;
   end
   if zx > 0
     j = 1;
   end
integral(k)=j;
   CTsat(k) = abs(sign(ipp(k)));%*integral(k));         % izracunamo obmocje
nasicenja
end

This code cannot be run because ip, CT, Rct, RB and so on are missing. Try to create a minimal and reproducible example.

-- Andy



reply via email to

[Prev in Thread] Current Thread [Next in Thread]