Code covered by the BSD License
-
DFiltFIR (NCof, BSpec, FType,...
-
Example1
-
Example2
-
Example3
-
MMBSpec (BSpec, SFreq, BSpecD...
Check and fill in missing band specifications
-
MMdSpec (FType, NCof, BSpec, ...
Convert band-by-band specifications into a specification on a dense
-
MMdesLPFIR (FType, NCof, Gc)
This routine designs multiple band bandpass filters, differentiators,
-
MMprintSpec (FType, NCof, dev...
This routine prints the design parameters for an FIR filter.
-
PrMatrix (Banner, x)
Pretty print a matrix. For the most compact printout, transpose column
-
StartDiaryFile (LogFile, RefF...
This routine is used for test scripts. All output from the test script
-
tDFiltFIR (LogFile)
-
tinterp1
Script illustrating an undesired behaviour in interp1
-
View all files
from
DFiltFIR
by Peter Kabal
Design linear-phase FIR filters - with upper/lower constraints and flexible specifications
|
| MMdSpec (FType, NCof, BSpec, GridD)
|
function Gc = MMdSpec (FType, NCof, BSpec, GridD)
% Convert band-by-band specifications into a specification on a dense
% grid of points.
%
% Gc: Structure containing the specifications on a dense grid of points
%
% FType: Filter type.
% 1 - Multiple passband/stopband filter
% 2 - Multiple passband/stopband filter (sin(x)/x compensation)
% 3 - Differentiator
% 4 - Hilbert transform filter
% NCof: Number of filter coefficients
% BSpec: Band specifications
% GridD: Grid density. The number of points in the frequency grid used to
% determine the positions of the extrema of the approximating function
% is the product of GridD and the number of extrema (approximately
% Ncof/2). If GridD is NaN, the number of grid points is chosen to be
% the greater of 1000 or 16 times the number of extrema.
% Resolve the filter type
[FCase, NPar] = MM_FCase (FType, NCof);
% Convert to a specification on a dense grid of frequencies
GB = MMgrid (FCase, NPar, BSpec, GridD);
% Modify the specifications
% - Receiving filters - sin(x)/x compensation
% - Differentiators - change slope specification to value
% Transform the specifications for the different cases (odd/even number of
% coefficients, odd/even symmetry) into a common form for approximation by
% a sum of cosines. The grid frequencies are converted to cosine values,
% x = cos(2pi f).
Gc = MMmodSpec (FType, FCase, GB);
return
%-----------------
function [FCase, NPar] = MM_FCase (FType, NCof)
% Sym Asym
% FType: 1 2 3 4 bpf rec dif hil
FCaseData = [ 1 1 3 3; % NCof odd
2 2 4 4]; % NCof even
Parity = (mod (NCof, 2) == 0) + 1;
FCase = FCaseData (Parity, FType);
switch FCase
case 1
NPar = (NCof + 1) / 2;
case {2, 4}
NPar = NCof / 2;
case 3
NPar = (NCof - 1) / 2;
end
return
|
|
Contact us at files@mathworks.com