⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 6-2.m

📁 matlab数字信号与应用源代码6
💻 M
字号:
%例程6-2  计算非平稳随机信号的STFT时频谱
% e.g.6-2.m for example6-2;
 
clear;
N=500;      %length of the signal x.
t=0:N-1;
x=zeros(size(t));
%Generate two sine signal with different frequencies.
x(50:150)=cos(pi*(t(50:150)-50)/10);   
x(250:350)=cos(pi*(t(250:350)-250)/20);
subplot(221);
plot(x);
axis([ 0 500 -1 1]);
grid;
X=fft(x);
X=fftshift(X);         %Shift zero-frequency component to center of spectrum
subplot(222);
plot(abs(X));
axis([0 500 0 60 ]);
grid;
Nw=20;          %window length
L=Nw/2;
Ts=round((N-Nw)/L)+1;     
nfft=128;
TF=zeros(Ts,nfft);
for i=1:Ts
    xw=x((i-1)*L+1:i*L+L);
    temp=fft(xw,nfft);
    temp=fftshift(temp);
    TF(i,:)=temp;
end
subplot(223);
mesh(abs(TF));
subplot(224);
contour(abs(TF));
axis equal tight         % set the axes aspect ratio
grid;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -