Correct way to detect Zero crossing
Mostrar comentarios más antiguos
Hi i am implementing a power-electronics circuit that requires a zero current detector I implemented a crude function that checks if the current (through a current sensor) is more than a small quantity or not but due to this the simulation speed decreased drastically.
function y = ZCD(I)
if(I<1e-8)
y=1;
else
y=0;
end
Is there a more elegant way to find zerocrossings?
Respuesta aceptada
Más respuestas (1)
The entire function can be replaced with
y = I<1e-8;
which will return a logical (true | false). If you want a double (1 | 0),
y = double(I<1e-8);
Note that this doesn't necessarily identify zero crossings. It merely identifies values less than 1e-8.
Categorías
Más información sobre Switches and Breakers en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!