How to plot discrete time signals using STEM in MATLAB and Simulink?

This video shows the steps to implement a 3 harmonics periodic Analog signal. It further shows how one can plot the discrete time signal for the equation in both MATLAB and Simulink.

It writes a simple MATLAB script and uses STEM function to plot the discrete time signal. It also makes a Simulink model and in the scope block’s window it changes the style to STEM to display the discrete time signal.

In this video it uses the below Periodic Analog signal equation with three harmonics as an example:

y = sin(wt)-3cos(2wt)+2sin(3w*t);

I hope you like this video. For any questions, suggestions or appreciation please contact us at: or email at:

Complete source code and other details:

Matlab Script:

fs = 24;
w = 2*pi*fs;
t = 1:0.1:5;

y = sin(w*t)-3*cos(2*w*t)+2*sin(3*w*t);

plot(t,y, 'Marker', '*');


Simulink Model Design:

Leave a Reply