%% Construct a Complex Analog Filter
% Use fdesign.arbmagnphase to model a complex analog filter.

d = fdesign.arbmagnphase('n,f,h',100); % N=100, f and h set to defaults.
design(d,'freqsamp','SystemObject',true);

%
% For a more complex example, design a bandpass filter with low group delay by specifying the desired delay and using f and h to define the filter bands.

n = 50;     % Group delay of a linear phase filter would be 25.
gd = 12;    % Set the desired group delay for the filter.
f1=linspace(0,.25,30); % Define the first stopband frequencies.
f2=linspace(.3,.56,40);% Define the passband frequencies.
f3=linspace(.62,1,30); % Define the second stopband frequencies.
h1 = zeros(size(f1));  % Specify the filter response at the freqs in f1.
h2 = exp(-1j*pi*gd*f2); % Specify the filter response at the freqs in f2.
h3 = zeros(size(f3));  % Specify the response at the freqs in f3.
d=fdesign.arbmagnphase('n,b,f,h',50,3,f1,h1,f2,h2,f3,h3);
D = design(d,'equiripple','SystemObject',true);
fvtool(D,'Analysis','freq');

% Copyright 2012 The MathWorks, Inc.