Hi. I have a problem with the convolution (in black) that I don't know how to fix. The convolution is ok, but it should be transferred 5 units do the left (y+5). what could I do? Thanks!

4 views (last 30 days)
%convolution
u = [0.2, 0.4, 0.6, 0.8, 1, 0.8, 0.6, 0.4, 0.2];
n = 0:1:8;
v = [2,0,0,0,0,1,0,0,0,0,-1,0,0,0,0];
n2= 0:1:14;
stem(n,u);
hold on;
stem(n2,v);
hold on
y = conv(u,v);
plot(y,'k')

Accepted Answer

KSSV
KSSV on 9 Nov 2016
clc; clear all ;
%convolution
u = [0.2, 0.4, 0.6, 0.8, 1, 0.8, 0.6, 0.4, 0.2];
n = 0:1:8;
v = [2,0,0,0,0,1,0,0,0,0,-1,0,0,0,0];
n2= 0:1:14;
stem(n,u);
hold on;
stem(n2,v);
hold on
y = conv(u,v);
n3 = 5:length(y)+4 ;
plot(n3,y,'k')
You have plotted y, w.r.t it's indices. I have defined it's new positions and plotted. Is that okay?
  3 Comments
KSSV
KSSV on 9 Nov 2016
Edited: KSSV on 9 Nov 2016
Change n3 accordingly....
u = [0.2, 0.4, 0.6, 0.8, 1, 0.8, 0.6, 0.4, 0.2];
n = 0:1:8;
v = [2,0,0,0,0,1,0,0,0,0,-1,0,0,0,0];
n2= 0:1:14;
stem(n,u);
hold on;
stem(n2,v);
hold on
y = conv(u,v);
n3 = -4:length(y)-5 ;
plot(n3,y,'k')

Sign in to comment.

More Answers (0)

Categories

Find more on Elementary Math in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!