Comb function (derived from Sawtooth)

Here is another of those little utility functions that you think must exist in Igor, but doesn't seem to. It generates a periodic variable-symmetry rectangular wave of specified period and duty cycle, with amplitude of 1 or 0.
function comb(period, duty, x)
    variable period, duty, x
   
    return (sawtooth(2*pi*x/period)>=duty) ? 0 : 1
end

My apologies if I have missed anyone's prior contribution or any Igor documentation.

Forum

Support

Gallery

Igor Pro 8

Learn More

Igor XOP Toolkit

Learn More

Igor NIDAQ Tools MX

Learn More