I have implemented Haar Function in MATLAB based on formulas stated here. However this formulas generate functions only between 0 and 1 (on [0..1] interval). I need to generate such functions periodically from -infinity to +infinity for instance with period = 1. It should depend on length of my time vector. For example if time vector on interval [0..10] I should generate Haar function vector on the same interval [0..10]. I hope you get a point. Here is my MATLAB code.
function [ f ] = haar(x)
%Haar function
% x: time vector
vectorLength = length(x);
f = zeros(1, vectorLength);
for k = 1:vectorLength
if (x(k) >= 0 && x(k) < 1/2)
f(k) = 1;
elseif (x(k) > 1/2 && x(k) <= 1)
f(k) = -1;
end;
end;
end
max(x)-min(x)
$\endgroup$f = 1 - 2 * (mod(x,1) >= 0.5);
. $\endgroup$