Re: Sine wave code

Andreas Weber <[email protected]>
Newsgroups gmane.comp.gnu.octave.general
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.