I'm trying to graph a convolution based on a vector.
Here's what I have so far:
>> n=[-10:10];
>> x=zeros(1,length(n));
>> x(n==-1)=1;
>> x(n==0)=1;
>> x(n==1)=-1;
>> u=zeros(1,length(n));
>> u(n>=0)=1;
>> h=(1/2).^n .* u;
>> y = conv(x,h)
Now I want to graph y using stem(n,y)
or something like that but y
wouldn't be aligned to n
anymore as they are different lengths already.
Is there a way to align my old vector n
to my new equation y
when I'm graphing them? Or at least align my y-values to the right x-axis values.
use:
y= conv(x,h,'same')
This returns the central part of the convolution of the same size as x
.