Commit df9d9022 authored by Zapf's avatar Zapf
Browse files

moving average

parent 9965931a
clear all
close all
d= importdata('test_sensordaten.log');
%d= importdata('31-07-18-Noise.log');
d= importdata('31-07-18-Standing.log');
k1=0.98;
k2=1-k1;
a=0.999;
b=1-a;
Gyro_Phi_p= d(:,1);
Acc_Phi=d(:,2);
Phi_korr=d(:,3);
windowSize = 10;
b = (1/windowSize)*ones(1,windowSize);
a = 1;
Acc_fil = filter(b,a,Acc_Phi);
T=length(Gyro_Phi_p)/200;
t=0.005:0.005:T;
Gyro_Phi(1)= Phi_korr(1);
Phi_korr_2(1)= Phi_korr(1);
Phi_korr_3(1)= Phi_korr(1);
for i=2:length(Gyro_Phi_p)
Gyro_Phi(i)=Gyro_Phi(i-1)+Gyro_Phi_p(i)/200;
Phi_korr_2(i)=a*(Phi_korr_2(i-1)+Gyro_Phi_p(i)/200) ...
+b*Acc_Phi(i);
Phi_korr_2(i)=k1*(Phi_korr_2(i-1)+Gyro_Phi_p(i)/200) ...
+k2*Acc_Phi(i);
Phi_korr_3(i)=k1*(Phi_korr_3(i-1)+Gyro_Phi_p(i)/200) ...
+k2*Acc_fil(i);
end
%plot(t,Gyro_Phi_p);
plot(t,Gyro_Phi);
hold on
plot(t,Acc_Phi);
plot(t,Acc_fil);
plot(t,Phi_korr);
plot(t,Phi_korr_2);
plot(t,Phi_korr_3);
legend(...%'Gyro Winkelgeschwindigkeit',...
'Gyro Winkel',...
'Acc Winkel',...
'Acc Winkel gefiltert',...
'korrigierter Winkel',...
'korrigierter Winkel Matlab');
\ No newline at end of file
'korrigierter Winkel Matlab',...
'korrigierter Winkel Matlab Filter');
\ No newline at end of file
d= importdata('test_sensordaten.log');
Gyro_Phi_p= d(:,1);
Acc_Phi=d(:,2);
Phi_korr=d(:,3);
T=length(Gyro_Phi_p)/200;
t=0.005:0.005:T;
Gyro_Phi(1)= Phi_korr(1);
for i=2:length(Gyro_Phi_p)
Gyro_Phi(i)=Gyro_Phi(i-1)+Gyro_Phi_p(i-1)/200;
korr_Phi
end
%plot(t,Gyro_Phi_p);
plot(t,Gyro_Phi);
hold on
plot(t,Acc_Phi);
plot(t,Phi_korr);
legend(...%'Gyro Winkelgeschwindigkeit',...
'Gyro Winkel',...
'Acc Winkel',...
'korrigierter Winkel')
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment