官方说明
TFRSP为Spectrogram time-frequency distribution,即时频分布谱图。
函数原型为 [TFR,T,F]=TFRSP(X,T,N,H,TRACE) ,用于计算离散时间信号X的谱图分布。
X : 信号
T : 时间序列(s) (默认 : 1:length(X))。
N : 频率数 (默认 : length(X))。指的是频率分辨率
H : 分析窗,H是正规化的以便成为单位能量 (默认 : Hamming(N/4))。
TRACE :如果非零,则显示算法的进展 (默认 : 0)。
TFR : 时频表达式。当没有输出参数时,TFRSP运行TFRQVIEW,用自带的图形显示窗口显示。
F : 正规化的频率矢量。
具体使用
生成待分析的信号
首先我们用fmlin这个函数生成一个长度为128,正规化频率由0.1逐渐变为0.4的线性调频信号:
sig=fmlin(128,0.1,0.4);
用plot(real(sig))可以看到其波形:
sig其实是复数,其模始终为1:
下面我们将用这个信号进行时频分析。
设置窗函数
由于tfrsp函数的输入参数H为窗函数,所以我们需要选择一个合适的窗函数。为什么在时频分析时要选择窗函数,并且选择什么样的窗函数、窗的尺寸是多少,请参考相关文章。如:https://www.vfe.cc/NewsDetail-2239.aspx
这里我们选择Kaiser窗函数,并设置长度为17,参数默认(3*pi)。
h=tftb_window(17,'Kaiser');
设置参数
我们按照官方说明的要求,逐一设置参数,信号为sig,时间点为1至128,频率数为64,窗函数为h,显示算法进展:
tfrsp(sig,1:128,64,h,1);
由于没有输出参数,所以直接运行调用了TFRQVIEW,结果如下:
可以看到命令行窗口显示了算法进度,并自动产生了TFRQVIEW显示窗口,谱图显示频率从0.1变化为0.4。
输出参数
我们使用imagesc(tfr)来观察第一个输出的参数。结果如下:
由于我们的频率数设置为64,所以纵坐标轴的值除以64才是正规化后的频率,即0.1至0.4。