使用“cumsum”或Omega算术方法从加速度数据(10 Hz)获取速度

问题描述 投票:0回答:1

我想从 MATLAB 中的加速度数据(10 Hz)获取速度。我有通过(DeltaX/DeltaT)计算的真实恒定速度。问题是,当我使用下面的代码时,该图与真实速度图有很多差异。我使用了 cumsum 和 omega 算术,有人可以告诉我这两种方法的代码是否有任何问题吗?先感谢您。 访问txt文件的链接:https://spaces.hightail.com/space/19rl7

%%%%%%%%%%%%%%% cumsum METHOD %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
fid1 = fopen( 'Acceleration_data.txt', 'r' );
fid2 = fopen( 'Actual_Velocity_data.txt', 'r' );
formatSpec = '%f';
vel_Fast_Running = fscanf(fid2,formatSpec);
acc_Fast_Running = fscanf(fid1,formatSpec);
Fs=1000;
Ns = 10;%% Sampling freq
T = 1/Fs; %% Period
L = length(acc_Fast_Running); %% signal length
acceleration_data=acc_Fast_Running-median(acc_Fast_Running);
[B,A] = butter(6,0.098,'high'); %% highpass filter
a_filtr = filtfilt(B,A,acc_Fast_Running); %% acceleratiof w/o DC
v_cumsum = cumsum(a_filtr)*0.1;%integration
v_cumsum = v_cumsum - mean(v_cumsum);
[B,A] = butter(3,0.12,'low'); 
v_cumsum_filtr = filtfilt(B,A,v_cumsum);
%subplot(1,2,2);plot([v_cumsum' v_cumsum_filtr']);
hold on;plot(vel_Fast_Running)
plot(v_cumsum_filtr)
legend('Actual Vel','Vel From integration')
xlabel('Time')
ylabel('Velocity m/s')

%%%%%%%%%%%%%%% OMEGA ARITHMETIC METHOD %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
fid1 = fopen( 'Acceleration_data.txt', 'r' );
fid2 = fopen( 'Actual_Velocity_data.txt', 'r' );
formatSpec = '%f';
vel_Fast_Running = fscanf(fid2,formatSpec);
acc_Fast_Running = fscanf(fid1,formatSpec);
Fs=1000;
Ns = 10;%% Sampling freq
T = 1/Fs; %% Period
L = length(acc_Fast_Running ); %% signal length
%t=(1:L)/Fs;
f = Fs*(0:L-1)/L;
acc_Fast_Running =acc_Fast_Running -mean(acc_Fast_Running );
[B,A] = butter(6,0.098,'high'); %% highpass filter
a_filtr = filtfilt(B,A,acc_Fast_Running);
Y = (fft(a_filtr)); % Fast fourier Transform
for i = 1 : L 
   if f(i) ~= 0 && f(i) < Fs/2;
       Yf(i) = Y(i)/(2*pi*f(i)*sqrt(-1)) ;
   else  
       Yf(i) = 0;
   end
end
Yf(1:100)=0; %% 
d_oa = real(ifft(Yf));
d1 = designfilt('lowpassiir','FilterOrder',4, ...
 'HalfPowerFrequency',0.1,'DesignMethod','butter');
y = filtfilt(d1,d_oa);
figure(15)
%plot( d_oa)
subplot(2,1,1)
plot(y)
xlabel('Time')
ylabel('Vel be Omega Method')
subplot(2,1,2)
plot(vel_Fast_Running )
xlabel('Time')
ylabel('Actual Velocity m/s')

matlab integration velocity cumsum acceleration
1个回答
0
投票

我最近开发了一种使用 FFT 和高通滤波器的算法。我已经使用另一个实验加速度和速度数据验证了它。

我还使用您的速度和加速度数据来回答您的问题。但我使用经过验证的算法获得的结果与您的非常相似。我认为你的速度数据可能是错误的。

© www.soinside.com 2019 - 2024. All rights reserved.