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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started