Correct way to detect Zero crossing
Show older comments
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?
Accepted Answer
More Answers (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.
Categories
Find more on Switches and Breakers in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!