研究中经常会用到将加速度数据积分成速度和位移,对前几年编写的程序重新进行了改写。为了测试和验证peer2acc函数、dirFolder函数和acc2vd函数,编写了一个简单的测试程序 acc2vd函数主要信息如下: %% Main information % Developed by Decai@hfut 2014/11/14 % Calculate velocity displacement from acceleration through integration %% Description of input output variables % ---input variables % acc: acceleration data % dt: time step % ---output variables % vel: velocity data % dis: displacement data %% Format to use % vel=acc2vd(acc,dt) % or =acc2vd(acc,dt) 函数附件: acc2vd.p 测试程序如下: clear all clc direc='test'; filenames=dirFolder(direc); =peer2acc(direc,filenames{1}); =acc2vd(acc,dt); t=dt:dt:N*dt; subplot(311) plot(t,acc); ylabel('acceleration'); subplot(312) plot(t,vel); ylabel('velocity'); subplot(313) plot(t,dis); xlabel('t') ylabel('displacement'); 运行结果: