0001 function A=nt_narrowband_scan(x,freqs,sr,Q,plotflag,yulewalk_order)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 if nargin<6; yulewalk_order=[]; end
0018 if nargin<5; plotflag=[]; end
0019 if nargin<4||isempty(Q); Q=[8 4]; end
0020 if nargin<3; error('!'); end
0021
0022 freqs=freqs(:);
0023
0024 if ~isempty(yulewalk_order)
0025 error('use nt_yulewalk_whiten() to whiten data before this function');
0026 end
0027
0028
0029 current_figure=get(0,'CurrentFigure');
0030 A={};
0031 for iFreqs=1:numel(freqs)
0032 freq=freqs(iFreqs);
0033 [b,a]=nt_filter_peak(freq/(sr/2),Q(1));
0034 [c0,c1]=nt_bias_filter(x,b,a);
0035 if numel(Q)==2
0036 [b,a]=nt_filter_peak(freq/(sr/2),Q(2));
0037 [~,c0]=nt_bias_filter(x,b,a);
0038 end
0039 [todss,pwr0,pwr1]=nt_dss0(c0,c1);
0040
0041 if 1; figure(100); clf; plot(pwr1./pwr0,'.-'); title([num2str(freq), 'Hz bias']); ylabel('score'); drawnow;end
0042
0043 A{iFreqs}=todss;
0044 end
0045
0046
0047 if ~nargout || ~isempty(plotflag)
0048 if isempty(current_figure);
0049 figure;
0050 else
0051 figure(current_figure);
0052 end
0053 AA=zeros(size(x,2),numel(freqs));
0054 for iFreqs=1:numel(freqs)
0055 AA(:,iFreqs)=A{iFreqs}(:,1);
0056 end
0057 x=nt_mmat(x,AA);
0058 nfft=2.^nextpow2(size(x,1)+1)/2;
0059 MAX_NFFT=1024;
0060 nfft=min(nfft,MAX_NFFT);
0061 nt_spect_plot2(nt_normcol(x),nfft,[],[],sr);
0062 K=round(numel(freqs)/6);
0063 set(gca,'ytick',1:K:numel(freqs), 'yticklabel',num2str(freqs(1:K:end), '%.3g')); ylabel('Hz');
0064 set(gca,'xgrid','on','xminortick','on');
0065 drawnow;
0066 clear A;
0067 end
0068