[249cf9]: comp / comp_fourierwindow.m Maximize Restore History

Download this file

comp_fourierwindow.m    120 lines (101 with data), 2.7 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
function [g,info] = comp_fourierwindow(g,L,callfun);
%COMP_FOURIERWINDOW Compute the window from numeric, text or cell array.
% Usage: [g,info] = comp_fourierwindow(g,a,M,L,wilson,callfun);
%
% `[g,info]=comp_fourierwindow(g,L,callfun)` will compute the window
% from a text description or a cell array containing additional
% parameters.
%
% See also: gabwin, wilwin
% Basic discovery: Some windows depend on L, and some windows help define
% L, so the calculation of L is window dependant.
% Default values.
info.gauss=0;
info.isfir=0;
% Manually get the list of window names
definput=arg_firwin(struct);
firwinnames = definput.flags.wintype;
% Create window if string was given as input.
if ischar(g)
winname=lower(g);
switch(winname)
case {'pgauss','gauss'}
complain_L(L,callfun);
g=comp_pgauss(L,1,0,0);
info.gauss=1;
info.tfr=1;
case {'psech','sech'}
complain_L(L,callfun);
g=psech(L,1);
info.tfr=1;
otherwise
error('%s: Unknown window type: %s',callfun,winname);
end;
end;
if iscell(g)
if isempty(g) || ~ischar(g{1})
error('First element of window cell array must be a character string.');
end;
winname=lower(g{1});
switch(winname)
case {'pgauss','gauss'}
complain_L(L,callfun);
[g,info.tfr]=pgauss(L,g{2:end});
info.gauss=1;
case {'psech','sech'}
complain_L(L,callfun);
[g,info.tfr]=psech(L,g{2:end});
case firwinnames
g=firwin(winname,g{2:end});
info.isfir=1;
otherwise
error('Unsupported window type.');
end;
end;
if isnumeric(g)
if size(g,2)>1
if size(g,1)>1
error('g must be a vector');
else
% g was a row vector.
g=g(:);
end;
end;
g_time=g;
g=struct();
g.h=fftshift(g_time);
info.gl=numel(g_time);
g.offset=-floor(info.gl/2);
g.fc=0;
g.realonly=0;
info.wasreal=isreal(g.h);
else
if isstruct(g)
if isfield(g,'h')
info.wasreal=isreal(g.h);
info.gl=length(g.h);
info.isfir=1;
else
info.wasreal=g.realonly;
info.gl=[];
if ~isempty(L)
if ~isnumeric(g.H)
g.H=g.H(L);
g.foff=g.foff(L);
end;
end;
end;
else
% Information to be determined post creation.
info.wasreal = isreal(g);
info.gl = length(g);
if (~isempty(L) && (info.gl<L))
info.isfir=1;
end;
end;
end;
function complain_L(L,callfun)
if isempty(L)
error(['%s: You must specify a length L if a window is represented as a ' ...
'text string or cell array.'],callfun);
end;