MATLAB: I want to envelope the damped curve with an exponential function passing through the peak points. Can someone please help

envelope

X = A1(exp(-alpha*t)).*cos(wd*t)+ A2*(exp(-alpha*t)).*sin(wd*t)* is the equation of the damped curve.
The parameters are t=0:0.000050:0.1; A1 = 12.87701558; A2 = -12.70012814; alpha = 67.91641; wd = 4770.680551
The equation of the enveloping curve is I = Io * exp(-67.91641*t)
where Io is the peak values of the damped curve
I am attaching the image of damped curve as well as its enveloping curve through peak points.

Best Answer

Since it is a second-order system, the envelop parameter Io can be analytically expressed as a function of A1 and A2. The following function follows from the trigonometric identities.
Io = sqrt(A1^2+A2^2);
Try the following code,
t=0:0.000050:0.1;
A1 = 12.87701558;
A2 = -12.70012814;
alpha = 67.91641;
wd = 4770.680551;
X = A1*(exp(-alpha*t)).*cos(wd*t)+ A2*(exp(-alpha*t)).*sin(wd*t);
Io = sqrt(A1^2+A2^2);
I = Io * exp(-67.91641*t);
plot(X);
hold on;
plot(I, 'Color', 'r')
plot(-I, 'Color', 'r')