using acceleration record, Get velocity and displacement signal & carry out FFT and plot the spectra

24 views (last 30 days)
Given information
  • Time domain signal file : GEE Earthquke.xlsx (attached)
  • Sampling rate (frequency): 64Hz
  • Acceleration values in g (9.81m/s^2)
1) Velocity and displacement signal
  • Consider baseline correction
  • Get the relative velocity and displacement signals
  • Plot the signals
  • Get the amplitude parameters in time domain (peak acceleration, peak velocity and peak displacement)
2) Carry out the FFT and plot the spectra
P.S No matter how much I think and try, I can't code.. plz help me

Accepted Answer

Mathieu NOE
Mathieu NOE on 30 Mar 2022
hello
see my suggestion below
clc
clearvars
data = readmatrix('GEE Earthquake.xlsx');
t = data(:,1);
dt = mean(diff(t)); % Average dt
fs = 1/dt; % Frequency [Hz] or sampling rate
% Acceleration data
acc = data(:,2)*9.81; % Add gravity factor ( g to m/s²)
acc = detrend(acc); % baseline correction
% some additionnal high pass filtering % baseline correction
N = 2;
fc = 0.25; % Hz
[B,A] = butter(N,2*fc/fs,'high');
acc = filter(B,A,acc);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
velocity = cumtrapz(dt,acc);
velocity = detrend(velocity); % baseline correction
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
disp = cumtrapz(dt,velocity);
disp = detrend(disp); % baseline correction
%
figure(1)
subplot(311),plot(t,acc);
title('accel'); ylabel('m/s²');xlabel('time (s)');
subplot(312),plot(t,velocity);
title('velocity'); ylabel('m/s');xlabel('time (s)');
subplot(313),plot(t,disp);
title('disp'); ylabel('m');xlabel('time (s)');
%%fft
nfft = length(acc);
fft_spectrum = (abs(fft(disp,nfft))/nfft);
% one sidded fft spectrum % Select first half
if rem(nfft,2) % nfft odd
select = (1:(nfft+1)/2)';
else
select = (1:nfft/2+1)';
end
fft_spectrum = fft_spectrum(select,:);
freq_vector = (select - 1)*fs/nfft;
figure(2)
plot(freq_vector,fft_spectrum);
title('disp'); ylabel('m');xlabel('time (s)');
xlim([0 10]);
  6 Comments
Changhyun Kim
Changhyun Kim on 12 Aug 2022
in fact,, it doesn't work. The built-in function called butter keeps getting an error and the script cannot be executed.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!