Extracted envelope via Hilbert Transform is tracking the signal 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?

Sampling Period: 0.01s


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:
Computing the envelope of a signal via the Hilbert transform only works well for bandpass signals.

But apart from that, you're not taking into account the delay of the Hilbert transformer when creating the analytic signal. It would be easier to choose an odd filter length $N$, because then you get an integer delay:

$$d=\frac{N-1}{2}$$

Also note that there's the command hilbert for directly computing the analytic signal. Furthermore, there's a function envelope that lets you choose different methods for computing the envelope of a signal.