function haar_t = evalHaarFunction(N, t)
    
    nfun = 2^(N+1);
    
    haar_t = zeros(nfun, size(t,2));
 
    haar_t(1,:) = 1;
    haar_t(2,:) = (t <= 1/2) - (t > 1/2);
    
    for n = 1:N
        val = 2^(n/2);
        dn = 2^n;
        for k = 2^n:2^(n+1)-1
            haar_t(k+1,:) =   val*(t >= (k - dn      )/dn).*(t < (k - dn + 0.5)/dn) ...
                            - val*(t >= (k - dn + 0.5)/dn).*(t < (k - dn + 1  )/dn);
        end
    end
    
end