function [y,yhat] = stp(x, M) % [0,1] periodic step function with jumps at x = 0, 0.5. % Returns N-vector of gridpoint values y at gridpoints x % uniformly spaced over [0,1) and vector of Fourier coeffs yhat(M) % ordered like the entries of M. y = sign(x - 0.5); % y = -1 for 0