I have data that is in general units called Digital Units vs Milliseconds, which I need to convert to ground acceleration and apply filtering. However, the first step is to convert the data from time-domain to freqency-domain. I have used the Excel file "TestFile.xlsx" which I have attached, to generete the original plot, and compute the single-sided spectrum P1 based on Ps and even-valued signal length (L) as recommneded by the MATLAB Help. However, I get a plot that does not make much sense to me, and I am not sure if I need to fix something.
This is the code that I did:
close all
clear
clc
filename = 'TestFile.xlsx';
% Load excel table
M = readtable(filename);
%disp(T);
% Load column as vectors
ms = table2array(M(:,1)); % Time Vector
lpx = table2array(M(:,2)); % Signal + Noise
T = 604; % Sampling Period
Fs = 1/T; % Sampling frequency
L = 4211;
%t = (0:L-1)*T
figure
plot(ms,lpx)
title('Original signal before filtering')
xlabel('t millisecond')
ylabel('Digital Units')
% Computing Fourier transform of signal
Y = fft(lpx);
%Compute the single-sided spectrum P1 based on P2 and the even-valued
%signal length L
P2 = abs(Y/L);
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
figure
f = Fs*(0:(L/2))/L;
plot(f,P1)
title('Single-Sided Amplitude Spectrum of X(t)')
xlabel('f(Hz)')
ylabel('|P1(f)|')