I want to design a filter with a custom phase delay related to frequency. As frequency increases, phase delay should increase.
The time delay as a function of frequency can be expressed as: $t_d = \frac{L}{C_{ph}} - \frac{1}{f}$
$L$ and $C_{ph}$ are constants of $0.0017$ and $2628$ respectively.
The range of $f$ is $500\mathrm{kHz}$ to $1 \mathrm{MHz}$, the sampling frequency, $f_s$ is $78.39\mathrm{MHz}$.
Thus, when the frequency is $500 \mathrm{kHz}$, the delay should be $1.37\mathrm{\mu s}$ or $107$ samples.
For the pass band, $f$, I have used a filter response of $e^{-i2\pi fd}$, where $d$ is the delay in samples required.
I have designed stop bands with a filter response of zero between $0 \mathrm{Hz}-100\mathrm{kHz}$ and $1.4 \mathrm{MHz}-f_s$.
In MATLAB my code looks like this:
n = 50; fs = double(fs); L = double(L); Cph = 2628; f1 = linspace(500e3/fs,1e6/fs,100); f1d = L/Cph - (1./(f1*fs)); %Our array is backwards though innit f1d = f1d * -1; f1dz = f1d * fs; h1 = exp(-1i*2*pi*f1.*f1dz); fstop1 = linspace(0,100e3/fs, 10); hstop1 = zeros(size(fstop1)); fstop2 = linspace(1.4e6/fs, 1, 10); hstop2 = zeros(size(fstop2)); d=fdesign.arbmagnphase('n,b,f,h', n, 3, fstop1, hstop1, f1, h1, fstop2, hstop2); %d=fdesign.arbmagnphase('n,b,f,h', n, 1, f1, h1); D = design(d,'equiripple'); fvtool(D,'Analysis','phasedelay'); This is what I get:
Markers are at 500k and 1M.
What am I doing wrong?
