Why do signals differ in fdesign.fracdelay and dsp.VariableFractionalDelay?
2 views (last 30 days)
Show older comments
Hello!
I use two Matlab functions that implement the 3rd order Farrow filter (fdesign.fracdelay and dsp.VariableFractionalDelay).
These functions give different results.
Below is a code and a graph of the absolute value of the difference of the signals at the outputs of the filters.
Why does an error occur if the coefficient must be the same?
close all;
clearvars;
clc;
%% Parameters
% Signal
fs = 2000; % Sampling frequency
t = (0 : 1/fs : 2 - 1/fs).'; % Time
s = chirp(t-2, 4, 1/2, 6, 'quadratic', 100, 'convex').*exp(-4*(t-1).^2); % Signal
% Delay
d = 0.9;
%% FFT-delay
s_d = delayseq(s, d);
%% Farrow filter 3-rd order
fd = fdesign.fracdelay(d, 'N', 3);
cubicfarrow = design(fd, 'lagrange', 'FilterStructure', 'farrowfd');
y_farrow = filter(cubicfarrow, s);
%% Variable Fractional Delay
vfd = dsp.VariableFractionalDelay('InterpolationMethod', 'Farrow');
y_vfd = vfd(s, d);
%% Error
Err = abs(y_farrow - y_vfd);
Err_farrow = abs(s_d - y_farrow);
Err_vfd = abs(s_d - y_vfd);
%% Pots
hSig = figure ('Units', 'Normalized', ...
'Position', [0.1, 0.1, 0.8, 0.8], ...
'PaperOrientation', 'landscape', ...
'NumberTitle', 'off', ...
'Name', 'Signal', ...
'Tag', 'Fig_Sig');
movegui(hSig, 'center');
hold on;
ps = plot(t, s, 'Color', 'Red', 'LineWidth', 3);
psd = plot(t, s_d, 'Color', 'Black', 'LineWidth', 3);
psfarrow = plot(t, y_farrow, 'Color', 'Blue', 'LineWidth', 2);
psvfd = plot(t, y_vfd, 'Color', 'Magenta', 'LineWidth', 2);
hold off;
grid on;
legend([ps, psd, psfarrow, psvfd], 'Signal', 'FFT', 'fractdelay', 'VariableFractionalDelay');
hErr = figure ('Units', 'Normalized', ...
'Position', [0.1, 0.1, 0.8, 0.8], ...
'PaperOrientation', 'landscape', ...
'NumberTitle', 'off', ...
'Name', 'Errors', ...
'Tag', 'Fig_Err');
movegui(hSig, 'center');
hold on;
pe = plot(t, Err, 'Color', 'Red', 'LineWidth', 3);
pefarrow = plot(t, Err_farrow, 'Color', 'Blue', 'LineWidth', 2);
pevfd = plot(t, Err_vfd, 'Color', 'Magenta', 'LineWidth', 2);
hold off;
grid on;
legend([pe, pefarrow, pevfd], '|farrow - vfd|', 'fractdelay', 'VariableFractionalDelay');
![Err.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/197499/Err.png)
0 Comments
Answers (1)
Honglei Chen
on 29 Nov 2018
Your dsp.VariableFractionalDelay is actually order 4. If you do
vfd = dsp.VariableFractionalDelay('InterpolationMethod', 'Farrow', 'FilterLength', 3);
The result of vfd and cubicfarrow will match.
HTH
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!