function [x,y,z]=stp(in)
%STP  Return sine, pulse and triangle waves.
%	[X, Y, Z] = STP(IN) computes the sine of input vector IN (X), 
%	a triangle wave with peaks at the peaks of the sine wave (Y).
%	a pulse wave whose value is 1 at the sine wave peaks, and 0 else (Z).

%	T Kite February 1997, 1998

l=length(in);
x=sin(in);
y=asin(x)*2/pi;
xpad=[0 abs(x) 0];
z=sign(x) .* (xpad(2:l+1) >= xpad(3:l+2) & xpad(2:l+1) > xpad(1:l));
