tfar.m

来自「biomedical stuffs...」· M 代码 · 共 34 行

M
34
字号
function specs=tfar(sig, order,long,shift,fmin,fmax,fs)
%  time-freq analysis using AR spectra
%  specs=tfar(sig, order,long,shift,fmin,fmax,fs)
%  'sig' is analyzed in blocks of size 'long'
%  with consecutive blocks offset by amount 'shift'
%  spectra are calculated for 100 points between fmin and fmax
%
%	This program is distributed as a supplement to the book
%	"Biomedical Signal Processing and Signal Modeling" by E. N. Bruce,
%	published by Wiley, 2000.  It is provided for educational use only.
%  While every effort has been made to insure its suitability to illustrate
%  principles described in the above book, no specific feature or capability 
%  is implied or guaranteed.
ns=fix((length(sig)-long)/shift)
specs=zeros(100,ns+1);
w=2*pi*linspace(fmin/fs,fmax/fs);
for j=1:ns
	inx=(j-1)*shift+1;
	th=ar(detrend(sig(inx:(inx+long))),order,'fb','ppw');
	sptemp=th2ff(th,0,w);
	specs(:,j)=sptemp(2:101,2);
end
specs(:,j+1)=linspace(fmin,fmax)';
timeindx=[0:shift:shift*(ns-1)]/fs;
figure(1)
mesh(timeindx,linspace(fmin,fmax),specs(:,1:ns));view(120,60);grid;
title('Time-frequency spectral plot')
xlabel('Time (sec)');ylabel('Frequency (Hz)')
figure(2)
contour(timeindx,linspace(fmin,fmax),specs(:,1:ns));grid;
title('Contours of time-frequency spectral plot')
xlabel('Time (sec)');ylabel('Frequency (Hz)')

⌨️ 快捷键说明

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