大家帮调下程序!
看看怎么提高分辨率啊,现在程序误差很大!谢谢!clear
clc
figure(1)
T=0.02;
fs=120/0.02;
Ts=1/fs;
N=T/Ts;
n=0:N-1;
t=(0:N-1)*Ts;
f0=400;
x=cos(5/7*pi*f0*t);
% [x,fs]=wavread('a2.wav');
% t=(0:length(x)-1)/fs;
% T=(length(x)-1)/fs;
% Ts=1/fs;
% N=T/Ts;
subplot(221)
plot(t*Ts,real(x))
X=fft(x);
X=fftshift(X);
% m=0:N-1;
% f=(m-N/2)*fs/N;
subplot(222)
% plot(t,abs(X))
plot((t-N/2)*fs/N,abs(X))
Nw=20;
L=Nw/2;
Tn=(N-Nw)/L+1;
nfft=32;
TF=zeros(Tn,nfft);
for i=1:Tn
xw=x((i-1)*10+1:i*10+10);
% xw=x(((i-1)*10+1)/fs:(i*10+10)/fs);
temp=fft(xw,nfft);
temp=fftshift(temp);
TF(i,:)=temp;
end
subplot(223)
fnew=((1:nfft)-nfft/2)*fs/nfft;
tnew=(1:Tn)*L*Ts;
[F,T]=meshgrid(fnew,tnew);
mesh(F,T,abs(TF))
subplot(224)
contour(T,F,abs(TF))