题目:x(n) = {x(0), x(1), x(2)} = {1,3,2}, h(n) = {h(0), h(1), h(2), h(3)}={4,3,2,1}。 (1)计算y(n) = x(n) * h(n);
(2)分别计算出x(n)与h(n)4点、5点和6点的循环卷积。 解:
(1)matlab代码:
X = [1 3 2]; H = [4 3 2 1]; Y = conv(H,X);
figure(1); nX = 0:length(X)-1; nH = 0:length(H)-1; nY = 0:length(Y)-1; subplot(3,1,1); stem(nX,X);
xlabel('Time index n'); ylabel('Amplitude'); title('x(n)'); grid on; subplot(3,1,2); stem(nH,H);
xlabel('Time index n'); ylabel('Amplitude'); title('h(n)'); grid on; subplot(3,1,3); stem(nY,Y);
xlabel('Time index n'); ylabel('Amplitude'); title('y(n)= x(n)*h(n)'); grid on;
结果如下:
X = 1 3 2 H = 4 3 2 1
Y = 4 15 19 13 7 2
(2)matlab代码:
X = [1 3 2]; H = [4 3 2 1]; N4 = 4; N5 = 5; N6 = 6; figure(2);
% -------------------4点循环卷积------------------------------------------ X4 = fft(X,N4); H4 = fft(H,N4); yy = X4.* H4; Y4 = ifft(yy,N4); nY4 = 0:length(Y4)-1;
subplot(3,1,1); stem(nY4,Y4);
grid on; xlabel('Time index n'); ylabel('Amplitude'); title('y(n)-4点循环卷积'); % -------------------5点循环卷积------------------------------------------ X5 = fft(X,N5); H5 = fft(H,N5); yy = X5.* H5; Y5 = ifft(yy,N5); nY5 = 0:length(Y5)-1;
subplot(3,1,2); stem(nY5,Y5);
grid on; xlabel('Time index n'); ylabel('Amplitude'); title('y(n)-5点循环卷积'); % -------------------6点循环卷积------------------------------------------ X6 = fft(X,N6); H6 = fft(H,N6); yy = X6.* H6; Y6 = ifft(yy,N6); nY6 = 0:length(Y6)-1;
subplot(3,1,3); stem(nY6,Y6);
grid on; xlabel('Time index n'); ylabel('Amplitude'); title('y(n)-6点循环卷积');
结果如下:
X = 1 3 2
H = 4 3 2 1 Y4 = 11 17 19 13
Y5 = 6.0000 15.0000 19.0000 13.0000 7.0000
Y6 = 4.0000 15.0000 19.0000 13.0000 7.0000 2.0000
结果如下图: