"Levelling" out a signal with moving average

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

Sean de Wolski
Sean de Wolski 2012년 2월 23일
Huh? Could you elaborate a little more, perhaps with an image of a plot to help explain? If you want a more constant average - expand your window length.
Tom
Tom 2012년 2월 23일
If it is fairly sinusoidal, you could do an FFT (or several over different 'windows' of data) to determine the time period of one oscillation, and work out an average over this period?
Sandy
Sandy 2012년 2월 23일
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.

댓글을 달려면 로그인하십시오.

 채택된 답변

Sean de Wolski
Sean de Wolski 2012년 2월 23일

0 개 추천

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

Sandy
Sandy 2012년 2월 23일
I'm a beginner at signal processing so I'm not entirely sure what the capabilities of each function are but from what I can tell, both the medfilt1 and smooth functions are used to remove noise, if I'm correct?
The noise of the signal is fine, what I need right now is to have all the sine waves in straight line, so to speak. Kind of like this:
http://dl.dropbox.com/u/22993792/signal.jpg
Sandy
Sandy 2012년 2월 23일
Apologies, I mean like this:
http://dl.dropbox.com/u/22993792/signal2.jpg
Tom
Tom 2012년 2월 23일
I had a very quick look-I think you could use the medfilt1 function, but you'd have to know how many points to smooth over, which kind of comes back to the frequency of it- unless you take a bit of a stab with a large number. But someone may know a cleverer way than this.
Honglei Chen
Honglei Chen 2012년 2월 23일
@Sandy, I think you may want to find out first whether your original data is a power function or an exponential function. Then you do either polyfit or expfit like suggested by Gurudatha there. You can then try to subtract the fitted trend from the data. medfilt1 might work too but you then need to play with different window length. IMHO, the other approach is easier. I don't think smooth apply here. Also, smooth is not from Signal Processing Toolbox, it is from curve fitting toolbox.
Sandy
Sandy 2012년 2월 23일
Thank you all so much! The medfilt1 idea seems to have worked quite well. As suggested, I used medfilt1 to smooth the data as much as possible so it was practically just a single non-linear line and subtracted that from my original result:
http://dl.dropbox.com/u/22993792/medfilt1result.jpg
Unfortunately, it looks like there may be a problem with the initial value as it looks like it starts at 1.4 and immediately falls to 0. Anyhow, I will have a closer look at the problem.
Once again, all the help was very much appreciated!
Honglei Chen
Honglei Chen 2012년 2월 23일
You will have to drop the edge if you use medfilt1 because that is your transient response.

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Honglei Chen
Honglei Chen 2012년 2월 23일

0 개 추천

Maybe you want to try detrend?
doc detrend

댓글 수: 2

Sandy
Sandy 2012년 2월 23일
Thanks,
I've had a look at the detrend function and it seems that it's for linear trends. I tried using the function on my results and unfortunately it didn't make a difference.
The trend I have decreases non-linearly, kind of like the results here:
http://www.sensorprod.com/research-articles/white-papers/2005_nop/Representative-data-of-Pressure01.jpg
Honglei Chen
Honglei Chen 2012년 2월 23일
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.

댓글을 달려면 로그인하십시오.

Gurudatha Pai
Gurudatha Pai 2012년 2월 23일

0 개 추천

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.

카테고리

질문:

2012년 2월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by