FFT and CZT transform
FFT
Use the FFT algorithm to calculate the linear convolution of the sequence x(n)=[2,1,3,2,1,5,1] and h(n)=[1,2,-1,-3] and draw the input , Waveform diagram of output sequence.
x=[2 1 3 2 1 5 1];
h=[1 2 -1 -3];
N=length(x)+length(h)-1;
n=0:N-1;
x=[x,zeros(1,N-length(x))];
h=[h,zeros(1,N-length(h))];
X=fft(x);
H=fft(h);
Y=X.*H;
y=ifft(Y);
subplot(1,3,1);
stem(n,x,'.');
xlabel('n');
ylabel('x(n)');
title('x(n)');
grid;
subplot(1,3,2);
stem(n,h,'.');
xlabel('n');
ylabel('h(n)');
title('h(n)');
grid;
subplot(1,3,3);
stem(n,y,'.');
xlabel('n');
ylabel('y(n)');
title('y(n)');
grid;
The results are shown in the figure:
Knowing that the analog signal xa(t) is shown below, try the FFT algorithm to find the spectrum of xa(t).
Requirements: The
sampling time interval T is 0.05s, 0.02s, 0.01s, and 0.01s, and the number of sampling points is 200, 500, 1000, and 2000. Try the FFT algorithm to draw the frequency spectrum (amplitude spectrum) of these four situations.
T0=[0.05,0.02,0.01,0.01];
L0=[10,10,10,20];
for i=1:4
T=T0(i);
N=L0(i)/T0(i);
D=2*pi/(N*T);
n=0:N-1;
x=exp(-0.02*n*T).*cos(6*pi*n*T)+2*cos(14*pi*n*T);
k=floor(-(N-1)/2:(N-1)/2);
X=T*fftshift(fft(x));
[i,X(i)]
subplot(2,2,i);
plot(k*D,abs(X));
axis([min(k*D),max(k*D),0,inf]);
str=['T=',num2str(T),'N=',num2str(N)];
title(str);
end
The results are shown in the figure:
CZT transformation
Given that N=128, f1=8Hz, f2=8.22Hz, f3=9Hz, fs=40Hz, the sequence x(n) is as follows:
Requirements:
(1) Use CZT to find the DFT spectrum of x(n) (CZT transformation when A=1);
(2) Use FFT directly to find the spectrum of x(n);
(3) Use CZT to find x(n) ) Spectrum, the starting frequency point of the analysis is 7.2Hz, the frequency interval is 0.05Hz, M=60;
Draw the spectrograms under these three conditions and analyze them.
N=128;
f1=8;f2=8.22;f3=9;fs=40;
stepf=fs/N;
n=0:N-1;
t=2*pi*n/fs;
n1=0:stepf:fs/2-stepf;
x=sin(f1*t)+sin(f2*t)+sin(f3*t);
M=N;
W=exp(-j*2*pi/M);
% A=1ʱµÄczt±ä»»
A=1;
Y1=czt(x,M,W,A);
subplot(311)
plot(n1,abs(Y1(1:N/2)));grid on;
% DTFT
Y2=abs(fft(x));
subplot(312)
plot(n1,abs(Y2(1:N/2)));grid on;
% Ïêϸ¹¹ÔìAºóµÄczt
M=60;
f0=7.2;
DELf=0.05;
A=exp(j*2*pi*f0/fs);
W=exp(-j*2*pi*DELf/fs);
Y3=czt(x,M,W,A);
n2=f0:DELf:f0+(M-1)*DELf;
subplot(313);plot(n2,abs(Y3));grid on;
The results are shown in the figure:
Analysis: The frequency spectrum of the two sinusoids with frequencies of 8Hz and 8.22Hz is not easy to distinguish. In the third figure, the points are thinner, and the spectrum lines of the three sinusoids can be distinguished.