Diff of /fourier/blfilter.m [34f3ea] .. [931198] Maximize Restore

  Switch to unified view

a/fourier/blfilter.m b/fourier/blfilter.m
1
function g=blfilter(name,fsupp,varargin)
1
function gout=blfilter(name,fsupp,varargin)
2
%BLFILTER  Construct a band-limited filter
2
%BLFILTER  Construct a band-limited filter
3
%   Usage:  g=blfilter(name,fsupp,centre);
3
%   Usage:  g=blfilter(name,fsupp,centre);
4
%           g=blfilter(name,fsupp,centre,...);
4
%           g=blfilter(name,fsupp,centre,...);
5
%
5
%
6
%   `blfilter(name,fsupp)` construct a band-limited filter. The
6
%   `blfilter(name,fsupp)` construct a band-limited filter. The
...
...
9
%   the frequency response measured in normalized frequencies is
9
%   the frequency response measured in normalized frequencies is
10
%   specified by *fsupp*.
10
%   specified by *fsupp*.
11
%
11
%
12
%   `blfilter(name,fsupp,centre)` constructs a filter with a centre
12
%   `blfilter(name,fsupp,centre)` constructs a filter with a centre
13
%   frequency of *centre* measured in normalized frequencies.
13
%   frequency of *centre* measured in normalized frequencies.
14
%
15
%   If one of the inputs is a vector, the output will be a cell array
16
%   with one entry in the cell array for each element in the vector. If
17
%   more input are vectors, they must have the same size and shape and the
18
%   the filters will be generated by stepping through the vectors. This
19
%   is a quick way to create filters for |filterbank| and |ufilterbank|.
14
%
20
%
15
%   `blfilter` accepts the following optional parameters:
21
%   `blfilter` accepts the following optional parameters:
16
%
22
%
17
%     'fs',fs     If the sampling frequency *fs* is specified then the support
23
%     'fs',fs     If the sampling frequency *fs* is specified then the support
18
%                 *fsupp* and the centre frequency *centre* is specified in Hz.
24
%                 *fsupp* and the centre frequency *centre* is specified in Hz.
...
...
43
definput.keyvals.fs=[];
49
definput.keyvals.fs=[];
44
definput.flags.real={'complex','real'};
50
definput.flags.real={'complex','real'};
45
51
46
[flags,kv]=ltfatarghelper({'centre'},definput,varargin);
52
[flags,kv]=ltfatarghelper({'centre'},definput,varargin);
47
53
54
[fsupp,kv.centre,kv.delay]=scalardistribute(fsupp,kv.centre,kv.delay);
55
48
if ~isempty(kv.fs)
56
if ~isempty(kv.fs)
49
    fsupp=fsupp/kv.fs*2;
57
    fsupp=fsupp/kv.fs*2;
50
    kv.centre=kv.centre/kv.fs*2;
58
    kv.centre=kv.centre/kv.fs*2;
51
end;
59
end;
52
60
53
% Sanitize
61
% Sanitize
54
kv.centre=modcent(kv.centre,2);
62
kv.centre=modcent(kv.centre,2);
55
63
64
Nfilt=numel(fsupp);
65
gout=cell(1,Nfilt);
66
for ii=1:Nfilt
67
    g=struct();
56
g.H=@(L)    fftshift(firwin(name,round(L/2*fsupp),flags.norm));
68
    g.H=@(L)    fftshift(firwin(name,round(L/2*fsupp(ii)),flags.norm));
57
g.foff=@(L) round(L/2*kv.centre)-floor(round(L/2*fsupp)/2);
69
    g.foff=@(L) round(L/2*kv.centre(ii))-floor(round(L/2*fsupp(ii))/2);
58
g.realonly=flags.do_real;
70
    g.realonly=flags.do_real;
59
g.delay=kv.delay;
71
    g.delay=kv.delay(ii);
60
g.fs=kv.fs;
72
    g.fs=kv.fs;
73
    gout{ii}=g;
74
end;
75
76
if Nfilt==1
77
    gout=g;
78
end;