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

📄 stft0629.m

📁 用短时傅立叶变换对信号进行时频分析
💻 M
字号:
% exa110702_specgram.m ,for example 11.7.2  and fig11.7.1
% to test specgram.m 
%-------------------------------------------------------------------------
%clear;
%t=0:0.001:1.024-.001; 
%N=1024; 

% 得到两个Chirp 信号,并相加;
%y1=chirp(t,0,1,350);
%y2=chirp(t,350,1,0);
%y=y1+y2;
%subplot(211);plot(t,y1);
%ylabel(' Chirp signal y1')

% 求两个Chirp 信号和的短时傅里叶变换;
%[S,F,T]=specgram(y,127,1,hanning(127),126); 
%subplot(212);
%surf(T/1000,F,abs(S).^2)
%view(-80,30);
%shading flat;
%colormap(cool);
%xlabel('Time')
%ylabel('Frequency')
%zlabel('spectrogram')
load tf.dat;
pt=tf(:,1);pf=tf(:,2);      %分离出时间和幅值信号
%subplot(311);
%plot(pt,pf);
title('Time Domain');   %绘制原时域信号图
[S,F,T]=specgram(pf,64,1E3,hanning(64),0);
subplot(311);
surf(T/1000,F,abs(S).^2);
view(-80,30);
shading flat;
colormap(cool);
xlabel('Time');
ylabel('Frequency');
zlabel('spectrum');


[S,F,T]=specgram(pf,128,1E3,hamming(128),0);
subplot(312);
surf(T/1000,F,abs(S).^2);
view(-80,30);
shading flat;
colormap(cool);
xlabel('Time');
ylabel('Frequency');
zlabel('spectrum');


[S,F,T]=specgram(pf,256,1E3,hamming(256),0);
subplot(313);
surf(T/1000,F,abs(S).^2);
view(-80,30);
shading flat;
colormap(cool);
xlabel('Time');
ylabel('Frequency');
zlabel('spectrum');


%[y,f,t,p] = spectrogram(pf,256,250,F,1E3,'yaxis');
%subplot(313);
%surf(t,f,10*log10(abs(p)),'EdgeColor','none');
%axis xy; axis tight;colormap(jet);view(0,90);
%xlabel('Time');
%ylabel('Frequency(Hz)')

      %t=0:0.001:2;                    % 2 secs @ 1kHz sample rate
      %x=chirp(t,0,1,150);             % Start @ DC, cross 150Hz at t=1sec 
      %F = 0:.1:100;
      % [y,f,t,p] = spectrogram(x,256,250,F,1E3,'yaxis'); 
      % NOTE: This is the same as calling SPECTROGRAM with no outputs.
      %surf(t,f,10*log10(abs(p)),'EdgeColor','none');   
      %axis xy; axis tight; colormap(jet); view(0,90);
      %xlabel('Time');
      %ylabel('Frequency (Hz)')


⌨️ 快捷键说明

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