"Levelling" out a signal with moving average

3 views (last 30 days)
Sandy
Sandy on 23 Feb 2012
I'm doing studies on stress-relaxation with a dynamic displacement. The result I have is a almost sinusoidal signal with a moving average (decreasing due to stress-relaxation).
I'm wondering what is the best way to shift all the waves so that instead of having a moving average, I can have a constant average?
Thanks!
  3 Comments
Sandy
Sandy on 23 Feb 2012
Here is a sample of the signal I have:
http://dl.dropbox.com/u/22993792/signal.jpg
I was initially thinking of doing it your way, Tom, but thought maybe there was a quick function in MATLAB that may do it for me quickly! I think if all else fails, manually averaging it will have to do.

Sign in to comment.

Accepted Answer

Sean de Wolski
Sean de Wolski on 23 Feb 2012
What about using medfilt1 in the signal processing toolbox?
doc medfilt1
Edit: more
pictures really are worth thousands of words
Use the median filter, medfilt1 to create a new vector and then subtract this from your original.
  6 Comments
Honglei Chen
Honglei Chen on 23 Feb 2012
You will have to drop the edge if you use medfilt1 because that is your transient response.

Sign in to comment.

More Answers (2)

Honglei Chen
Honglei Chen on 23 Feb 2012
Maybe you want to try detrend?
doc detrend
  2 Comments
Honglei Chen
Honglei Chen on 23 Feb 2012
Then what I can think of is to do a polyfit on your data and then subtract the resulting fit from your data. But I don't know how good it can work out.

Sign in to comment.


Gurudatha Pai
Gurudatha Pai on 23 Feb 2012
I would recommend fitting an exponential curve rather than a poly fit. e.g see example 8.10 in Steven M. Kay, "Fundamentals of Statistical Signal Processing: Estimation Theory." pp 257.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!