⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 assert_winready.m

📁 linear time-frequency toolbox
💻 M
字号:
function [winpos,L]=assert_winready(self,Lin,thisw,dofac,evalother,callfun)%ASSERT_WINREADY   Make sure that a window is ready for calculation.%   Usage:  [winpos,L]=assert_winready(self,Lin,thisw,dofac,evalother,callfun);%%   Input parameters:%       self      : Number of tfr object to use.%       L         : Length of transform.%       thisw     : Window to consider.%       dofac     : Compute factorization?%       evalother : Are we evaluating the other window?%       callfun   : Name of calling function.%   Output parameters:%       winpos    : Position of window to use%       L         : Transform length.%       %   winpos is normally equal to thisw, but might change if a tight%   window is being used.%%   evalother is used for explicitly evaluating the other window, in%   the case that it is needed, i.e. for candual, cantight etc. thisw%   must point to the other window, but istight will be ignored% The window can be speficied in several categories:%% 1) A previously determined FIR window.% 2) A not yet determined FIR window.% 3) A previously determined IIR window.% 4) A not yeat determined IIR window.%% We shall refer to the cases below.global TF_STORAGE;% Determine which window is requested, and which is the other window.% This changes if we are using a tight window.istight=TF_STORAGE.data{self}.istight;if (istight>0) && (~evalother)  thisw=istight;  otherw=3-thisw;else  otherw=3-thisw;end;winpos=thisw;wininfo=TF_STORAGE.data{self}.w{thisw};% Quick references.a=TF_STORAGE.data{self}.a;M=TF_STORAGE.data{self}.M;% Make sure the other window has been evaluated, if it is needed for% the calculation of this window.if wininfo.otherdepend  assert_winready(self,Lin,otherw,0,1,callfun);  gother=TF_STORAGE.data{self}.w{otherw}.g;  end;if wininfo.Lwin>0  % Handle case 1 and case 3.  % The window is an already calculated FIR window. Determine L and  % return as quickly as possible.  [b_junk,N_junk,L]=assert_L(Lin,wininfo.Lwin,a,M,callfun);    else  % Handle case 2 and case 4.    % Now we can determine L, since there is no fixed window size to respect.  % We simple use the signal length as the window length to avoid trouble.  [b_junk,N_junk,L]=assert_L(Lin,0,a,M,callfun);  end;% Determine and make quick references to the DGT information.dgtinfo=TF_STORAGE.data{self}.dgtinfo;L_dgt=L*dgtinfo.Lmul;a_dgt=dgtinfo.a;M_dgt=dgtinfo.M;% Case 2 and 4.if wininfo.Lwin<=0   % Choose a whole point even centering unless a half-point even centering  % is explicitly requested.  centering=0;  if dgtinfo.iseven==2    centering=.5;  end;    % The window has not yet been evaluated, or it has been evaluated to  % an incorrect size.  if (wininfo.Lwin==0) || (wininfo.Lwin<0 && wininfo.Lwin~=-L);         switch wininfo.name      case 'none'	error([callfun,': No window specified.']);      case {'pgauss','psech','gauss','sech'}	% Determine which of the parameters have been explicitly specified	% and which ones should be handled now.	if isempty(wininfo.funpars{1})	  tfr=a_dgt*M_dgt/L_dgt;	else	  tfr=wininfo.funpars{1};	end;	if isempty(wininfo.funpars{2})	  centering=0;	  if dgtinfo.iseven==2	    centering=0.5;	  end;	else	  centering=wininfo.funpars{2};	end;		   	switch wininfo.name	  case {'pgauss','gauss'}	    g=comp_pgauss(L_dgt,tfr,centering);	  case {'psech','sech'}	    g=psech(L_dgt,tfr,centering);	end;	Lwin=-L;      case 'phanning'	error('NOT DONE YET');      case 'candual'	g=candual(gother,a_dgt,M_dgt);	g=dgtinfo.winscale*g;	Lwin=-L;      case 'cantight'	g=cantight(gother,a_dgt,M_dgt);	g=sqrt(dgtinfo.winscale)*g;	Lwin=-L;      case 'pherm'	switch length(wininfo.funpars)	  case 1	    g=pherm(L_dgt,wininfo.funpars{1},a_dgt*M_dgt/L_dgt);	  case 2	    g=pherm(L_dgt,wininfo.funpars{1},wininfo.funpars{2});	  case 3	    % XXX missing support for centering.	    error('NOT DONE YET');	  otherwise	    length(wininfo.funpars)	    wininfo.funpars	    error('IMPOSSIBLE');	end;		Lwin=-L;      case 'pbspline'	error('NOT DONE YET');      case 'phanning'	error('NOT DONE YET');      case 'firdual'	error('NOT DONE YET');      case 'firtight'      	error('NOT DONE YET');    end;        g_dgt=g;    % Shift the window if requested.    if (dgtinfo.c_w>0)      g_dgt=circshift(g,dgtinfo.c_w);    end;      % Set the window and the size.    TF_STORAGE.data{self}.w{thisw}.g=g;    TF_STORAGE.data{self}.w{thisw}.g_dgt=g_dgt;    TF_STORAGE.data{self}.w{thisw}.Lwin=Lwin;    TF_STORAGE.data{self}.w{thisw}.hasfac=0;        % Reinitialize winfo, this might be needed two lines below:    wininfo=TF_STORAGE.data{self}.w{thisw};  end;end;% Calculate factorization if needed and if it has not yet been done.if ((dofac) && (abs(wininfo.Lwin)==L) && (wininfo.hasfac==0))  TF_STORAGE.data{self}.w{thisw}.gf=comp_wfac(TF_STORAGE.data{self}.w{thisw}.g_dgt,a_dgt,M_dgt);  TF_STORAGE.data{self}.w{thisw}.hasfac=1;end;    

⌨️ 快捷键说明

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