Try this modification instead. You almost had it right.
f = @(x) max(1-abs(x),0);
In your original function, when you translated it, you were seeing only one half of the abs function, and you were allowing it to go to -inf. The max that I added cuts off the function when it wants to go negative.