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

조회 수: 10 (최근 30일)
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

채택된 답변

Mathieu NOE
Mathieu NOE 2022년 3월 30일
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
Changhyun Kim
Changhyun Kim 2022년 8월 12일
in fact,, it doesn't work. The built-in function called butter keeps getting an error and the script cannot be executed.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Seismology에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by