|
clc
clear all;
SampFreq = 80;
% t= 0 : 1/SampFreq : 5;
t1= 1/SampFreq: 1/SampFreq : 2.5;
t2= 2.5 : 1/SampFreq : 5;
N=400;
t=(0:N-1)/SampFreq ;
c1 = 2 * pi * 10;
c2 = 2 * pi * 20;
Sig(1:200)=sin(c1*t1);
Sig(201:401)=sin(c2*t2);
%Sig = sin(c1*t1)+sin(c2*t2)
%figure(1)
%plot(t,Sig,'Line Width',2);
%N=length(S);
%subplot 211; plot(t,xx);
%xlabel('时间'); ylabel('幅值')
%title('信号波形');
%x=xx(1:1024);
nfft=400;
M=1024;
h=hanning(1023);
[tfr,t,f]=tfrstft(Sig,(1:400)/SampFreq,M,h);
%tfr=tfrstft(Sig)
figure(2);
imagesc(t/SampFreq ,f(1:512)*SampFreq ,abs(tfr(1:512,:)));
%axis('xy');
xlabel('时间'); ylabel('频率')
title('信号的STFT频谱');
??? Error using ==> tfrstft
X must have one column
Error in ==> text at 24
[tfr,t,f]=tfrstft(Sig,(1:400)/SampFreq,M,h);
运行时出错 |
|