From: cartonn on
I just needed to write these functions and thought they could be useful for others as well. And what makes them kind of cool is that they are all "one-liners" Here they are:

function [result] = unit_impulse(t)
result = -abs(sign(t))+1;
end

function [result] = unit_step(t)
result = ceil(ceil(sign(t)+.1)*.5);
end

function [result] = unit_ramp(t)
result = unit_step(t).*t-unit_step(t-1).*(t-1);
end