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

10 vues (au cours des 30 derniers jours)
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

Réponse acceptée

Mathieu NOE
Mathieu NOE le 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 commentaires
Changhyun Kim
Changhyun Kim le 12 Août 2022
in fact,, it doesn't work. The built-in function called butter keeps getting an error and the script cannot be executed.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Seismology dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by