I am trying to extract the envelope of the signal shown in blue, which is the low-pass filtered output of a second-order system. Low-pass filtering was done in order to reduce measurement noise. To be able to determine the decay of the system I want to extract the envelope of the signal. My MATLAB code looks as follows:
d = fdesign.hilbert(500,0.05);
hd = design(d,'equiripple','SystemObject',true);
coeff = hd.Numerator;
h = coeff / sum(abs(coeff));
y_hilb = 1i * filter(h, 1, y_filt);
y_an = y_filt + y_hilb;
env = abs(y_an);
Unfortunately, the envelope that I am extracting is actually tracking the signal rather than showing the actual envelope. What am I doing wrong here?
EDIT1: I changed the code as follows. Unfortunately, the result looks similar.
d = fdesign.hilbert(501,0.05);
delay = (N - 1) / 2;
y_an = y_filt(1 : end - delay) + 1j * y_hilb(delay + 1 : end);
EDIT2:
As suggested, I removed the scaling of the coefficients. Result: