频域采样点数N必须大于等于时域离散信号的长度M
才能使时域不发生混叠现象
x(n)=xa(nT)=Ae^(-a*nT) * sin(Ω0* nT) * u(nT)
使用不同的采样频率长度(点数)用公式N=Fs*Tp计算
FFT选用64,长度不够用补充零
X(k)=FFT[x(n)] k=0,1,2,3,…,M-1
clc
close all;
clear all;
Tp=50/1000;
Fs=1000;
T=1/Fs;
M=Tp*Fs;%M=50
n=0:max(M-1,64);
A=444.128;
alpha=pi*50*2^0.5;
omega=pi*50*2^0.5;
xnt=A*exp(-alpha*n*T).*sin(omega*n*T);
Xk=T*fft(xnt,M);
figure
subplot(2,1,1);
xlabel('n');
ylabel('xnt');
stem(n,xnt,'.');
axis([0,length(n),min(xnt),1.2*max(xnt)]);
title('Fs=1000hz');
k=0:M-1;
fk=k/Tp;
subplot(2,1,2);
plot(fk,abs(Xk));
axis([0,Fs,0,1.2*max(abs(Xk))]);
title('T*FT[xa(nT)],Fs=1000hz');
clc
close all;
clear all;
Tp=50/1000;
Fs=300;
T=1/Fs;
M=Tp*Fs;%M=50
n=0:max(M-1,64);
A=444.128;
alpha=pi*50*2^0.5;
omega=pi*50*2^0.5;
xnt=A*exp(-alpha*n*T).*sin(omega*n*T);
Xk=T*fft(xnt,M);
figure
subplot(2,1,1);
xlabel('n');
ylabel('xnt');
stem(n,xnt,'.');
axis([0,length(n),min(xnt),1.2*max(xnt)]);
title('Fs=300hz');
k=0:M-1;
fk=k/Tp;
subplot(2,1,2);
plot(fk,abs(Xk));
axis([0,Fs,0,1.2*max(abs(Xk))]);
title('T*FT[xa(nT)],Fs=300hz');
clc
close all;
clear all;
Tp=50/1000;
Fs=200;
T=1/Fs;
M=Tp*Fs;%M=50
n=0:max(M-1,64);
A=444.128;
alpha=pi*50*2^0.5;
omega=pi*50*2^0.5;
xnt=A*exp(-alpha*n*T).*sin(omega*n*T);
Xk=T*fft(xnt,M);
figure
subplot(2,1,1);
xlabel('n');
ylabel('xnt');
stem(n,xnt,'.');
axis([0,length(n),min(xnt),1.2*max(xnt)]);
title('Fs=200hz');
k=0:M-1;
fk=k/Tp;
subplot(2,1,2);
plot(fk,abs(Xk));
axis([0,Fs,0,1.2*max(abs(Xk))]);
title('T*FT[xa(nT)],Fs=200hz');
可以看出来1000hz时混叠很少
300hz混叠严重
200hz混叠更严重
clc
close all;
clear all;
M=27;
N=32;
n=0:M;
xa=1:floor(M/2)+1;
xb=ceil(M/2)-1:-1:0;
xn=[xa,xb];
figure
subplot(3,2,1);
stem(n,xn,'.');
axis([0,length(n),min(xn),1.2*max(xn)]);
title('x(n)');
xlabel('n');
ylabel('x(n)');
Xk=fft(xn,1024);%1024点FFT[x(n)],用于近似xn的FT
X32k=fft(xn,32);
x32n=ifft(X32k);
X16k=X32k(1:2:N);
x16n=ifft(X16k,N/2);
k=0:1023;
wk=2*k/1024;
subplot(3,2,2);
plot(wk,abs(Xk));
axis([0,2,0,1.2*max(abs(Xk))]);
title('FT[x(n)]');
xlabel('\omega/\pi');
ylabel('|X(e^j^\omega)|');
k=0:N-1;
subplot(3,2,3);
stem(k,abs(X32k),'.');
title('32-point frequence sample');
xlabel('k');
ylabel('|X32(k)|');
axis([0,32,0,1.2*max(abs(X32k))]);
n32=0:N-1;
subplot(3,2,4);
stem(n32,x32n,'.');
title('32-point IDFT[X32(k)]');
xlabel('n');
ylabel('|x32(n)|');
axis([0,32,0,1.2*max(x32n)]);
k=0:N/2-1;
subplot(3,2,5);
stem(k,abs(X16k),'.');
title('16-point frequence sample');
xlabel('k');
ylabel('|X16(k)|');
axis([0,16,0,1.2*max(abs(X16k))]);
n16=0:N/2-1;
subplot(3,2,6);
stem(n16,x16n,'.');
title('16-point IDFT[X16(k)]');
xlabel('n');
ylabel('|x16(n)|');
axis([0,16,0,1.2*max(x16n)]);