用FFT计算两个序列的线性卷积
x1=[0,2,2,1];
n1=0:length(x1)-1;
for i=1:16
x2(i)=1.02^(i-1);
end
for i=17:29
x2(i)=0.98^(i-1);
end
n2=0:length(x2)-1;
L=length(x1)+length(x2)-1;
N=0:L-1;
A=fft(x1,L);
B=fft(x2,L);
C=ifft(A.*B);
figure(1);
subplot(1,2,1);
stem(n1,x1);
xlabel('n1');
ylabel('x1');
subplot(1,2,2);
stem(n2,x2);
xlabel('n');
ylabel('x2');
figure(2);
subplot(2,2,1);
stem(N,A);
xlabel('n');
ylabel('A');
subplot(2,2,2);
stem(N,B);
xlabel('n');
ylabel('B');
subplot(2,2,3);
stem(N,C);