%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Project : Test Moving Average Filter
% Version : 1.00a
% Date : 2011.05.09
% Explanation : Test Program of MAF, Reference : A-Jin , Application of KalmanFilter
% Author : Yoon JaWoong
% CopyRight : MILab
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear all; close all; clc
load SonarAlt;
Nsamples = length(sonarAlt);
Xsaved = zeros(Nsamples, 1);
for k=1:Nsamples
x = MovAvgFilter2(10,sonarAlt(k));
Xsaved(k) = x;
end
dt = 0.02;
t = 0:dt:Nsamples*dt-dt;
figure
hold on
plot(t, sonarAlt, 'r.');
plot(t, Xsaved, 'b');
legend('Measured', 'Moving average')
b = ones(10,1)/10;
output = filtfilt(b,1,Xsaved);