1
function g=long2fir(g,varargin);
3
%@deftypefn {Function} long2fir
5
%LONG2FIR Cut LONG window to FIR
6
% Usage: g=long2fir(g,L);
8
% LONG2FIR(g,L) will cut the LONG window g to a length L FIR window by
9
% cutting out the middle part. Note that this is a slightly different
10
% behaviour than MIDDLEPAD.
12
% LONG2FIR(g,L,'wp') or LONG2FIR(g,L,'hp') does the same assuming the
13
% input window is a whole-point even or half-point even window,
17
%@strong{Url}: @url{http://ltfat.sourceforge.net/doc/fourier/long2fir.php}
18
%@seealso{fir2long, middlepad}
21
% Copyright (C) 2005-2014 Peter L. Soendergaard <soender@users.sourceforge.net>.
22
% This file is part of LTFAT version 2.0.1
24
% This program is free software: you can redistribute it and/or modify
25
% it under the terms of the GNU General Public License as published by
26
% the Free Software Foundation, either version 3 of the License, or
27
% (at your option) any later version.
29
% This program is distributed in the hope that it will be useful,
30
% but WITHOUT ANY WARRANTY; without even the implied warranty of
31
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32
% GNU General Public License for more details.
34
% You should have received a copy of the GNU General Public License
35
% along with this program. If not, see <http://www.gnu.org/licenses/>.
38
error('%s: Too few input parameters.',upper(mfilename));
41
definput.flags.centering = {'unsymmetric','wp','hp'};
42
definput.keyvals.L = [];
43
definput.keyvals.cutrel = [];
45
[flags,kv,L]=ltfatarghelper({'L'},definput,varargin);
50
error('L must be smaller than length of window.');
53
if ~isempty(kv.cutrel)
55
mask=abs(g)>maxval*kv.cutrel;
56
L=W-2*min(abs(find(mask)-L/2));
60
error(['%s: You must specify a way to shorten the window, either by ' ...
61
'specifying the length or through a flag.'],upper(mfilename));
64
if flags.do_unsymmetric
65
% No assumption on the symmetry of the window.
68
% HPE middlepad works the same way as the FIR cutting (e.g. just
69
% removing middle points) for even values of L.
70
g=middlepad(g,L,'hp');
72
% WPE middlepad works the same way as the FIR cutting (e.g. just
73
% removing middle points) for odd values of L.
84
g=middlepad(g,L,'hp');