Question: How do I write a n point symmetric weighted moving average filter using Matlab? For example a code that would let the user input an

How do I write a n point symmetric weighted moving average filter using Matlab?

For example a code that would let the user input an odd number that would serve as the n point, which could then be used to make the weighted filter.

I know that a 3 point symmetric weighted moving average filter looks something like this:

N = length(ECG);

for i = 2 : (N-1)

W3(i-1)= (ECG(i-1) + 2*ECG(i) + ECG(i+1))/4;

end

plot (time (2 : (N-1)), W3, g')

And a 5 point symmetric weighted average filter looks like:

for i = 3:(N-2)

W5(i-2) =(AV(i-2)+2*AV(i-1)+3*AV(i)+2*AV(i+1)+AV(i+2))/9;

end

plot(time(3:(N-2)),W5,'g');

But I'm not sure how to adjust the weights or how to form a for loop that will help distinguish the weights associated with different point filters.

Please Help with Matlab.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!