How to maintain sync in conv()

1 view (last 30 days)
Fredrik
Fredrik on 5 Nov 2012
I'm filtering a signal with a moving-average filter implemented by conv(). But there is some kind of sync error in the conv(), how it works I didn't quite understand. But I heard there is something with an overlap.
This is the code I use so far:
function E=calc_energy(X,winlen)
b=ones(1,winlen)/winlen;
E=conv(b,X);
So I have to do something with the parameters of conv() but since I don't understand how conv() overlaps I'm stuck.
Thankful for any help!
  1 Comment
Matt J
Matt J on 5 Nov 2012
Describe what you mean by "sync error".

Sign in to comment.

Accepted Answer

Matt J
Matt J on 5 Nov 2012
Edited: Matt J on 5 Nov 2012
Maybe this is what you want?
E=conv(b,X,'valid');
or this
E=conv(b,X,'same');

More Answers (0)

Community Treasure Hunt

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

Start Hunting!