not able to subtract two discrete signals

close all
clear all
n=-2:2
x(n~=0)=0
x(n==0)=1
subplot(3,1,1)
stem(n,x)
w(n~=2)=0
w(n==2)=1
subplot(3,1,2)
stem(n,w)
y=x-n
subplot(3,1,3)
stem(n,y)

 Respuesta aceptada

Star Strider
Star Strider el 12 de Abr. de 2015
I’m not certain that I understand what you are doing, but perhaps changing the ‘y’ assignment to:
y=x-w;
is what you want.

4 comentarios

irtaza anwar
irtaza anwar el 12 de Abr. de 2015
i am trying to plot &[n]-&[n-2]
Star Strider
Star Strider el 12 de Abr. de 2015
I believe that if you change your code to recalculate ‘y’ as I suggested, you will have what you want. You are subtracting two impulses separated in time by 2 time units, so the first one at n=0 will be plotted a +1 and the one at n=2 will be plotted as -1.
irtaza anwar
irtaza anwar el 12 de Abr. de 2015
thanks a lot
Star Strider
Star Strider el 12 de Abr. de 2015
My pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Preguntada:

el 12 de Abr. de 2015

Comentada:

el 12 de Abr. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by