function y = hat(x) % % y = hat(x) returns the value of % a hat function: % y = 0 for x < 0 and x > 1 % y = 1 for x >=0 and x <= 1. % if x < 0 y = 0; elseif x <= 1 y = 1; else y = 0; end