Use the hilbert function, specifically: DbEnv = abs(hilbert(Db));
Example —
t = 0:0.01:5;
s = sin(2*pi*t) .* cos(2*pi*10*t);
psenv = abs(hilbert(s));
nsenv = abs(hilbert(-s));
figure
plot(t, s, 'LineWidth',1.5)
hold on
plot(t, psenv, '-r', 'LineWidth',2)
plot(t, -nsenv, '-g', 'LineWidth',2)
hold off
grid
legend('Signal','Upper Envelope','Lower Envelope', 'Location','N')
.
Best Answer