Average Moving filter in Simulink
Mostrar comentarios más antiguos
Hey!
I don't have a DSP System Toolbox / Statistics, and I would like to create an average moving filter, and tune it.
I would appreciate any help, and thank in advance!
1 comentario
Mathieu NOE
el 11 de Oct. de 2023
hello
you can use a FIR filter of length N with 1/N values for all taps
other window are also doable if you want to weight the input data differently (hanning / hamming / kaiser etc...)
Respuesta aceptada
Más respuestas (1)
Why not use MATLAB code, e.g.:
t=linspace(0,2*pi);
S = sin(t); % Signal
R=randn(1,100); % Noise
S = S+R*.5; % Signal noise affected
N = 3; % 3-point moving average
S_ma(1)=S(1);
S_ma(2)=sum(S(1:3))/N;
for ii = 3:numel(R)
S_ma(ii)=(S(ii-2)+S(ii-1)+S(ii))/N;
end
plot(t, S)
hold on
plot(t,S_ma, 'r','LineWidth', 2)
% Compare to the MATLAB's moving average filter from finance toolbox
S_mat = movavg(S.', 'simple', N);
plot(t, S_mat, 'k--*')
legend('Signal', 'Code: moving average', 'Matlab"s movavg fcn', 'location', 'best')
grid on
xlabel('t')
ylabel('Signal: S(t)')
Categorías
Más información sobre Get Started with DSP System Toolbox en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

