[76dce7]: gabor / wilwin.m  Maximize  Restore  History

Download this file

218 lines (201 with data), 5.6 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
function [g,info] = wilwin(g,M,L,callfun);
%WILWIN Compute a Wilson/WMDCT window from text or cell array
% Usage: [g,info] = wilwin(g,M,L);
%
% `[g,info]=wilwin(g,M,L)` computes a window that fits well with the
% specified number of channels *M* and transform length *L*. The window itself
% is specified by a text description or a cell array containing additional
% parameters.
%
% The window can be specified directly as a vector of numerical
% values. In this case, `wilwin` only checks assumptions about transform
% sizes etc.
%
% `[g,info]=wilwin(g,M)` does the same, but the window must be a FIR
% window, as the transform length is unspecified.
%
% The window can be specified as one of the following text strings:
%
% 'gauss' Gaussian window with optimal concentration
%
% 'dualgauss' Riesz dual of Gaussian window with optimal concentration.
%
% 'tight' Window generating an orthonormal basis
%
% In these cases, a long window is generated with a length of *L*.
%
% It is also possible to specify one of the window names from |firwin|. In
% such a case, `wilwin` generates the specified FIR window with a length
% of *M*.
%
% The window can also be specified as cell array. The possibilities are:
%
% `{'gauss',...}`
% Additional parameters are passed to PGAUSS
%
% `{'dual',...}`
% Dual window of whatever follows. See the examples below.
%
% `{'tight',...}`
% Orthonormal window of whatever follows.
%
% It is also possible to specify one of the window names from |firwin| as
% the first field in the cell array. In this case, the remaining
% entries of the cell array are passed directly to |firwin|.
%
% Some examples::
%
% g=wilwin('gauss',M,L);
%
% This computes a Gaussian window of length L fitted for a system with
% *M* channels. ::
%
% g=wilwin({'gauss',1},M,L);
%
% This computes a Gaussian window with equal time and frequency support
% irrespective of *M*. ::
%
% gd=wilwin('gaussdual',M,L);
%
% This computes the dual of a Gaussian window fitted for a system with *M*
% channels. ::
%
% gd=wilwin({'tight','gauss'},M,L);
%
% This computes the orthonormal window of the Gaussian window fitted for
% the system. ::
%
% g=wilwin({'dual',{'hann',20}},M,L);
%
% This computes the dual of a Hann window of length 20.
%
% The structure info provides some information about the computed
% window:
%
% `info.gauss`
% True if the window is a Gaussian.
%
% `info.tfr`
% Time/frequency support ratio of the window. Set whenever it makes sense.
%
% `info.wasrow`
% Input was a row window
%
% `info.isfir`
% Input is an FIR window
%
% `info.isdual`
% Output is the dual window of the auxiliary window.
%
% `info.istight`
% Output is known to be a tight window.
%
% `info.auxinfo`
% Info about auxiliary window.
%
% `info.gl`
% Length of window.
%
% See also: pgauss, firwin, gabwin
% Assert correct input.
error(nargchk(2,4,nargin));
if nargin==2
L=[];
end;
% 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.wasrow=0;
info.isfir=0;
info.istight=0;
info.isdual=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,2*M*M/L,0,0);
info.gauss=1;
info.tfr=2*M*M/L;
case {'psech','sech'}
complain_L(L,callfun);
g=psech(L,2*M*M/L);
info.tfr=a*M/L;
case {'dualgauss','gaussdual'}
complain_L(L,callfun);
g=comp_pgauss(L,2*M*M/L,0,0);
g=wildual(g,M);
info.isdual=1;
info.tfr=a*M/L;
case {'tight'}
complain_L(L,callfun);
g=wilorth(M,L);
info.tfr=2*M*M/L;
info.istight=1;
case firwinnames
[g,firinfo]=firwin(winname,2*M,'2');
info.isfir=1;
if firinfo.issqpu
info.istight=1;
end;
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 {'dual'}
[g,info.auxinfo] = wilwin(g{2},M,L,callfun);
g = wildual(g,M,L);
info.isdual=1;
case {'tight'}
[g,info.auxinfo] = wilwin(g{2},M,L,callfun);
g = wilorth(g,M,L);
info.istight=1;
case firwinnames
g=firwin(winname,g{2},'energy',g{3:end});
info.isfir=1;
otherwise
error('Unsupported window type.');
end;
end;
if isnumeric(g)
if size(g,2)>1
if size(g,1)==1
% g was a row vector.
g=g(:);
info.wasrow=1;
end;
end;
end;
if rem(length(g),2*M)~=0
% Zero-extend the window to a multiple of 2*M
g=fir2long(g,ceil(length(g)/(2*M))*2*M);
end;
% Information to be determined post creation.
info.wasreal = isreal(g);
info.gl = length(g);
if (~isempty(L) && (info.gl<L))
info.isfir=1;
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;

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks