The N-Point Moving Average (MA) Filter

20 views (last 30 days)
Kutlu Yigitturk
Kutlu Yigitturk on 22 Apr 2021
- Write a Matlab code to load the input signal x[n],
clc
clear all
close all
N = input('Enter Order of Filter: ');
n = 0:N-1;
for k=n
y(k)=(1/N)*(sum(x(k:-1:k-N+1)))
end
plot(y(n))
I have such a solution for step 1, but I get an error. 'Unrecognized function or variable' x '.'
clc
clear all
close all
N = input('Enter Order of Filter: ');
n = 0:N-1;
x = 5;
for k=n
y(k)=(1/N)*(sum(x(k:-1:k-N+1)))
end
plot(y(n))
I get this error when I enter any value for X. 'Array indices must be positive integers or logical values.' How can I fix this problem?
- Then the reduce the noise of this signal using the given MA filter.
I do not know how to reduce the noise, I could not find a useful resource.
- Finally plot the original signal and the filtered one in the same figure.

Answers (0)

Community Treasure Hunt

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

Start Hunting!