Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
unit_impulse, unit_step and unit_ramp functions

Subject: unit_impulse, unit_step and unit_ramp functions

From: cartonn

Date: 31 Jan, 2010 23:50:02

Message: 1 of 1

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

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us