# 'Squashing' a graph of data?

I have a vector of sample data that describes a divergent oscillation like in this image.

I want to transform this data (just the data, not the system or anything), so that the data does converge to zero. I also want to keep the peaks of data at the same sample point, and the graph smooth. Simply multiplying the data by decreasing values moves the peaks of the data which is not desirable.

What sort of method should I use?

-
Maybe you could scale/bound the derivative, I believe you can force it to converge to zero. The peaks will stay the same, because scaling does not move zeros. –  dtldarek Mar 17 '12 at 12:20
Thanks, this could work, i'll give it a go in the morning. Any hints on how to do this in code/MATLAB? –  Projectile Fish Mar 17 '12 at 12:42
I tried this by taking the numerical derivative in MATLAB, scaling the derived vector by decreasing values over time, then integrating back with cumtrapz. The peaks do remain in the same place, however, an effect of this is that a constant offset has been introduced such that the data converges on a non-zero value, and I don't know why. Any ideas? –  Projectile Fish Mar 18 '12 at 0:25
This is why I wrote "I believe you can force it to converge to zero". If your function goes up and down, and you scale the derivatives, then every time it goes up a little bit slower, it goes down slower even more--you add a constant term. If it was the same speed for both up and down, then it would stay at zero, but now they differ. Not too much, but still. It's like doing three steps forward, but only two back. How to fix it: you can't add something that changes(that would move your peaks), but you can add a constant. There surely are some adaptive solutions, but I have no time for this. –  dtldarek Mar 18 '12 at 1:28

I did not get it. Do you have a function that generates this graphic? If so, you can multiply for a positive real function (say, $e^{-\alpha x}$, where you can adjust the value of $alpha >0$ for faster zero convergence). That should do if I got your question right.

-
I have data from a control system. There is no function that directly generates this data. The graphic is just for illustration of what a divergent oscillation looks like. Thanks! –  Projectile Fish Mar 17 '12 at 12:34
Wouldn't that change the position of peaks? For example $\sin' x = \cos x$, but $\left(e^{-\alpha x}\sin x\right)' = e^{-\alpha x} (-\alpha\sin x + \cos x)$ will have zeros in different places--the local extremes will move. –  dtldarek Mar 17 '12 at 15:43

If your function is $f(x)$, try $g(x) = -\int_x^\infty f'(t) h(t)\ dt$ where $h$ is some function that is always positive but decreases rapidly enough that $\int_0^\infty |f'(t)| h(t)\ dt < \infty$.

-

I assume you want your data to look like the graph on the left of the $Y$-axis, where $x <= 0$

To do that, simply multiply each $x$ value by $-1$.

FYI: The graph below is not your your data but looks somewhat close, it is the graph of $xsin(0.025x)$.

-