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