Question
How do I plot elementary discrete-time signals like unit impulse delta[n], unit step u[n], and unit ramp r[n] using MATLAB stem()?
Related Questions
Expert Answer
John Williams
PhD Expert
Answered Aug 8, 2026
Discrete-time signals are plotted using the stem() command in MATLAB. Below is a complete script generating unit impulse, step, and ramp signals:
n = -5:10; % Time index
% 1. Unit Impulse delta[n]
impulse = (n == 0);
% 2. Unit Step u[n]
step = (n >= 0);
% 3. Unit Ramp r[n]
ramp = n .* (n >= 0);
subplot(3,1,1); stem(n, impulse, 'filled'); title('Unit Impulse \delta[n]');
subplot(3,1,2); stem(n, step, 'filled'); title('Unit Step u[n]');
subplot(3,1,3); stem(n, ramp, 'filled'); title('Unit Ramp r[n]');
xlabel('n');
Have a different question? Ask here