How do I add zero padding to this convolution?

26 次查看(过去 30 天)
% My question is how do I add zero padding to this plot? I'm trying to show the effects of circular convolution with and without zero padding.
% This part is taking fourier transform of two different functions
a = 0.5;
n = [0,1,2,3,4,5,6,7];
x1 = a.^n;
x2 = [1,1,1,1,1,1,0,0];
X1 = fft(x1,16);
X2 = fft(x2,16);
% Here is the convolution of them. Need to add zero padding for this
% convolution plot
X1X2 = X1.*X2;
x1x2_conv = ifft(X1X2);

采纳的回答

Matt J
Matt J 2021-10-18
编辑:Matt J 2021-10-18
Not sure what the question is, but you can easily compare your result to direct convolution to see if it's correct.
x1x2_conv = ifft(X1X2)
x1x2_conv = 1×16
1.0000 1.5000 1.7500 1.8750 1.9375 1.9688 0.9844 0.4922 0.2422 0.1172 0.0547 0.0234 0.0078 0 -0.0000 -0.0000
conv(x1,x2)
ans = 1×15
1.0000 1.5000 1.7500 1.8750 1.9375 1.9688 0.9844 0.4922 0.2422 0.1172 0.0547 0.0234 0.0078 0 0
  2 个评论
Brianna Miranda
Brianna Miranda 2021-10-18
My question is how do I add zero padding to this plot. I'm trying to show the effects of circular convolution with and without zero padding. This code shows the effect without zero padding but I'm not sure how to add in zero padding.
Matt J
Matt J 2021-10-18
You have applied zero padding. To omit zero padding,
X1 = fft(x1);
X2 = fft(x2);

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Line Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by