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