Power spectral analyses on accelerometer data
Show older comments
Hi there,
I was hoping to get some clarification. I have 3D acceleration data in the x, y, and z-room oriented directions. Data attached (column 1: time; column 2: x-axis; column 3: z-axis; column 4: y-axis)
Below is a description of what I’m trying to achieve:
- Perform FFT
- Perform power spectral density using the periodogram function
- Perform power spectral density using the periodogram function to obtain the peak frequency between 3-15Hz using a sliding window of 1-s over each 3-s window with 50% overlap
I have bolded the areas in which the codes are not working. Is anyone able to identify my errors in the code below or clarify how to correctly perform the psd (psd performed on the FFT, and using a sliding window)?
t = data(:,1); % In seconds
L = size(data,1); % Data time vector length
Accel = data(:,2:end); % Accel data
Fs = 5000; % Sampling frequency (Hz)
Fn = Fs/2; % Nyquist
%FFT
FT_Accel = fft(Accel)/L;
FT_Accel_ampl = 2*abs(fft(Accel)/L);
FT_Accel_power = FT_Accel_ampl.^2;

%PSD
Ps = spectrum.periodogram;
psdest = psd(Ps, Accel,'Fs',Fs);
semilogx(psdest.Frequencies,10*log10(psdest.Data));
grid on;
%PSD - calculating peak frequency between 3-15Hz using a sliding window of 1 s over each 3 s window with 50% overlap
N = size(data,1);
window = 3*Fs; %3s window
[pxx,f] = periodogram(Accel,window,[],Fs,hanning(300000)); %is this not working because the '5000' Fs needs to be replaced with the nyquist? Default overlap of 50%
plot
Accepted Answer
More Answers (0)
Categories
Find more on Spectral Estimation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!