How can i cross check convolution in matlab
1 次查看(过去 30 天)
显示 更早的评论
My x(n)=delta(n) -delta(n-1)-delta(n-2) my h(n)= delta(n)+2delta(n-1)+3delta(n-2)-delta(n-4)
i have convolved them by hand i want to cross check my plot in matlab
how can i do that
0 个评论
回答(1 个)
Daniel Shub
2011-10-27
The hard part is that you want n to go from 0 to N-1, but MATLAB wants n to go from 1 to N. To get around this do everything in terms of m = n+1 and then subtract it off in the end ...
m = 1;
N = 10;
x = zeros(N, 1);
x(m) = 1;
x(m+1) = -1;
x(m+2) = -1;
h = zeros(N, 1);
h(m) = 1;
h(m+1) = 2;
h(m+2) = 3;
h(m+4) = -1;
figure;
subplot(2,2,1);
stem((1:N)-m, x);
title('x');
subplot(2,2,2);
stem((1:N)-m, h)
title('h');
subplot(2,2,3:4);
stem((1:(2*N-1))-m, conv(x,h));
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Subplots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!