How to plot discrete signals (delta equation)

78 views (last 30 days)
Jhon
Jhon on 3 Jun 2018
Answered: Abraham Boayue on 4 Jun 2018
plot 2 discrete signals:
1.x[n]=delta[n]-delta[n-1]+delta[n+4]
2.y[n]=0.5^n*u[n]
also plot the convolution I don't know what the delta is supposed to be and how to approach these kind of signals
if I have a simple signal I know how to do it n = 0:7; x1 = cos(pi*n); subplot(1,2,1) stem(n,x1)

Answers (1)

Abraham Boayue
Abraham Boayue on 4 Jun 2018
Take a look at this code. It shows how to plot the sequences that you are given.
n0 = 0;
n1 = 1;
n2 = -4;
n = -5:5;
xn = ((n-n0)==0)-((n-n1)==0)+((n-n2)==0); % The delta function
yn = 0.5*((n-n0)>=0);
figure
subplot(121)
stem(n,xn,'linewidth',3,'color','b')
a= title('Discrete time signal: Unit sample sequence');
set(a,'fontsize',14);
a= xlabel('n [-5 5]');
set(a,'fontsize',20);
a = ylabel('xn');
set(a,'fontsize',20);
grid
subplot(122)
stem(n,yn,'linewidth',3,'color','r')
a= title('Discrete time signal: Unit Step sequence');
set(a,'fontsize',14);
a= xlabel('n [-5 5]');
set(a,'fontsize',20);
a = ylabel('yn');
set(a,'fontsize',20);
grid

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!