How to Generate Discrete-Time Signals (Impulse, Step, Ramp) in MATLAB?

S
support · Jul 23, 2026 · 6 views
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()?
Expert Answer
Profile picture of John Williams
John Williams PhD Expert
Answered Aug 28, 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');
100% Run Guarantee 3-Hour Fast-Track Delivery

Need a Custom Version or Complete Simulation for This Problem?

Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.

Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here

Get a Free Consultation or a Sample Assignment Review!