added time average (which is the integral over the range divided by the range).
Here it is again:
Manipulate[Module[{data, i, x, area, average},
x = (-2*s*u[t]*r)*E^(-(r^2) - (t^2*(1.177^2))/(13.8)^2)*Cos[k*z - y*t];
data = Table[{i, x /. sol /. t -> i}, {i, -20, 20, .1}];
area = Integrate[u[t] /. sol, {t, -20, 20}];
average = area/(40); (*area = width*hight*)
data[[2]] = ListConvolve[Table[1/windowSize, {windowSize}], data[[All, 2]]];
Show[
ListLinePlot[data[[2]], DataRange -> {-20, 20}, Frame -> True,
FrameLabel -> {{"u(t)", None}, {"time (sec)",
Row[{"smoothed using windows size ", windowSize, " time average =", average}]}},
ImagePadding -> 30],
Plot[average, {x, -20, 20}, PlotStyle -> Red]
]
],
{{windowSize, 6, "window size?"}, 3, 20, 1},
ControlPlacement -> Top, Alignment -> Center,
ImageMargins -> 0, FrameMargins -> 0,
Initialization :> (
z = 0;
r = 0.7071;
s = 4.2758;
y = 2.2758;
system = {u'[t] == 2.2758*v[t], v'[t] == -2.2758*u[t] - 2*s*E^(-(r^2) - ((t^2*(1.177^2))/(13.8)^2))*Cos[k*z - y*t]*w[t],
w'[t] == 2*s*E^(-(r^2) - (t^2*(1.177^2))/(13.8)^2)*Cos[k*z - y*t]*v[t]};
initialvalues = {u[-20] == 0, v[-20] == 0, w[-20] == -1};
sol = First@NDSolve[Join[system, initialvalues], {u[t], v[t], w[t]}, {t, -20, 20}]
)
]