1 ## Author: Paul Kienzle <paulkienzle@Avocado.local> (2006)
2 ## This program is granted to the public domain.
5 ## @deftypefn {Function File} {@var{s} =} square(@var{t}, @var{duty})
6 ## @deftypefnx {Function File} {@var{s} =} square(@var{t})
7 ## Generate a square wave of period 2 pi with limits +1/-1.
9 ## If @var{duty} is specified, the square wave is +1 for
10 ## that portion of the time.
14 ## duty cycle = ------------------
18 ## @seealso{cos, sawtooth, sin, tripuls}
21 function v = square (t, duty = 0.5)
23 if (nargin < 1 || nargin > 2)
29 v(t-floor(t) >= duty) = -1;