rectangular function in matlab I am trying to program this function: $ g(t)= \operatorname{rect}(t/T) \,f(t)$

I take: $t=0:1:20$ and I know how to program $f(t)$.

But I have a problem with the rectangular function. How to program this function in matlab?
function y = rect(x);

    x = abs(x);

    if x == 0.5
        y = 0.5;
    else
        if  x &lt; 0.5
            y = 1;
        else
            y = 0;
        end
    end

end


put this in a file and name it "rect.m".  make sure it's on your MATLAB search path.