function MMprintSpec (FType, NCof, dev, BSpec, fid)
% This routine prints the design parameters for an FIR filter.
% $Id: MMprintSpec.m,v 1.6 2009/07/07 14:34:13 pkabal Exp $
if (~ exist ('fid', 'var'))
fid = 1;
end
dBV = @(x)(20 * log10 (x));
F_BPF = 1;
F_REC = 2;
F_DIF = 3;
F_HIL = 4;
DFM_BPF = 'Linear Phase FIR Filter';
DFM_REC = 'Linear Phase FIR Filter (sin(x)/x compensation)';
DFM_DIF = 'Differentiator';
DFM_HIL = 'Hilbert Transform Filter';
DIMF_Pars = ' No. Coef: %d\n';
DFMP_BPFheader = ...
' Freq. Value Weight Limits Deviation Dev dB';
DFMP_DIFheader = ...
' Freq. Slope Weight Limits Deviation';
DFMP_HILheader = ...
' Freq. Value Weight Limits Deviation';
DFMP_BandS = 'Band %2d:%7.4f %10.3g %10.3g ';
DFMP_BandC = ' %7.4f %10.3g %10.3g ';
% Preamble
switch FType
case F_BPF
fprintf (fid, '%s\n', DFM_BPF);
fprintf (fid, DIMF_Pars, NCof);
fprintf (fid, '%s\n', DFMP_BPFheader);
case F_REC
fprintf (fid, '%s\n', DFM_REC);
fprintf (fid, DIMF_Pars, NCof);
fprintf (fid, '%s\n', DFMP_BPFheader);
case F_DIF
fprintf (fid, '%s\n', DFM_DIF);
fprintf (fid, DIMF_Pars, NCof);
fprintf (fid, '%s\n', DFMP_DIFheader);
case F_HIL
fprintf (fid, '%s\n', DFM_HIL);
fprintf (fid, DIMF_Pars, NCof);
fprintf (fid, '%s\n', DFMP_HILheader);
end
% Design specifications
NBand = length (BSpec);
for (k = 1:NBand)
NVal = length (BSpec(k).f);
for (i = 1:NVal)
if (i == 1)
fprintf (fid, DFMP_BandS, k, BSpec(k).f(i), BSpec(k).V(i), BSpec(k).W(i));
else
fprintf (fid, DFMP_BandC, BSpec(k).f(i), BSpec(k).V(i), BSpec(k).W(i));
end
% Limits
if (isinf (BSpec(k).LL(i)))
fprintf (fid, ' ---- ');
else
fprintf (fid, '%10.3g ', BSpec(k).LL(i));
end
if (isinf (BSpec(k).UL(i)))
fprintf (fid, ' ---- ');
else
fprintf (fid, '%10.3g ', BSpec(k).UL(i));
end
% Calculate the deviation
devW = dev / BSpec(k).W(i); % Weighted deviation
excU = min (BSpec(k).V(i) + devW, BSpec(k).UL(i));
excL = max (BSpec(k).V(i) - devW, BSpec(k).LL(i));
devWM = max (excU - BSpec(k).V(i), BSpec(k).V(i) - excL);
fprintf (fid, '%9.2g', devWM);
% The printed deviation in dB is the larger of the dB value of
% the plus excursion or the minus excursion.
if (FType == F_BPF || FType == F_REC)
if (devWM > 0)
if (BSpec(k).V(i) ~= 0 && excL > 0)
RU = excU / BSpec(k).V(i);
RL = BSpec(k).V(i) / excL;
devdB = dBV (max (RU, RL));
else
devdB = dBV (devWM);
end
fprintf (fid, ' %7.2f', devdB);
else
fprintf (fid, ' ****');
end
end
fprintf (fid, '\n');
end
end
return