%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Project : Test 1st Order Low-Pass Filter
% Version : 1.00a
% Date : 2011.05.11
% Explanation : Test Program of 1st order LPF, 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);
Xsaved2 = zeros(Nsamples, 1);
%% MAF
for k=1:Nsamples
x = MovAvgFilter2(10,sonarAlt(k));
Xsaved(k) = x;
end
dt = 0.02;
t = 0:dt:Nsamples*dt-dt;
%% LPF
for k=1:Nsamples
x2 = LPF(0.9,sonarAlt(k));
Xsaved2(k) = x2;
end
figure
hold on
%plot(t, sonarAlt, 'r.');
plot(t, Xsaved, 'b');
plot(t, Xsaved2, 'k');
legend('Moving average','1st order LPF')
%% The charactoristic of Filter
freqz(0.7,[1,-0.3],1000,50)