Borrar filtros
Borrar filtros

creating spectra of bicycle vibration measurements

5 visualizaciones (últimos 30 días)
Bartek Brodacz
Bartek Brodacz el 13 de Dic. de 2021
Respondida: Abhinaya Kennedy el 2 de Abr. de 2024
Hi. My task is to analyze acceleration signal of bike vibrations. I have to create FFT and PSD spectra. The question is is the code i used for this task correct? Do the spectra that arise make sense?
rawdata=load('time axes modules.dat')
F_x=rawdata(:,4);
D = F_x; % Column Vector
L = numel(D); % Signal Length
Fs = 8000; % Sampling Frequency (Hz)
Fn = Fs/2; % Nyquist Frequency (Hz)
Ts = 1/Fs; % Sampling Interval (sec)
t = linspace(0, L, L)*Ts;
rms(D)
rms(D)^2
figure(1)
plot(t, D);
grid
xlabel('Time (sec)')
ylabel('Amplitude')
title('Time axe module Oś');
FTs = fft(D)/L; % Fourier Transform
Fv = linspace(0, 1, fix(L/2)+1)*Fn; % Frequency Vector
Iv = 1:length(Fv); % Index Vector
Phs = angle(FTs);
figure(2)
plot(Fv, abs(FTs(Iv))*2)
grid
xlabel('Frequency Hz)')
ylabel('Amplitude m/s^2')
figure(3)
N = length(D);
xdft = fft(D);
xdft = xdft(1:N/2+1);
plot(freq,10*log10(xdft))
grid on
title('Periodogram Using FFT')
xlabel('Frequency (Hz)')
ylabel('Power/Frequency (dB/Hz)')

Respuestas (1)

Abhinaya Kennedy
Abhinaya Kennedy el 2 de Abr. de 2024
Hi Bartek,
Your code for analysing the acceleration signal of bike vibrations and for creating FFT and PSD spectra is mostly correct, but there are a few improvements that could be made.
  • Frequency Vector for PSD Plot: You should define the frequency vector (freq) used in the PSD plot section. It seems you intended to use “Fv” but used “freq” instead.
  • PSD Calculation: To calculate the PSD plot correctly, you need to square the magnitude of the FFT components and normalize them for a proper PSD representation.
  • FFT Normalization and Scaling: Your FFT normalization and scaling are mostly correct for a single-sided spectrum but ensure this is intentionally excluding the DC and possibly the Nyquist frequency component.
rawdata = M; % Assuming .mat file, not .dat
D = rawdata{:,4}; % This extracts the fourth column as an array if rawdata is a table;
L = numel(D); % Signal Length
Fs = 8000; % Sampling Frequency (Hz)
Fn = Fs/2; % Nyquist Frequency (Hz)
Ts = 1/Fs; % Sampling Interval (sec)
t = linspace(0, L-1, L)*Ts; % Corrected time vector to start from 0 to (L-1)*Ts
% Plotting the signal
figure(1)
plot(t, D);
grid
xlabel('Time (sec)')
ylabel('Amplitude')
title('Time Axis Module');
% FFT
FTs = fft(D)/L; % Fourier Transform
Fv = linspace(0, Fn, fix(L/2)+1); % Corrected Frequency Vector to match xdft length
Iv = 1:length(Fv); % Index Vector
% Plotting FFT
figure(2)
plot(Fv, abs(FTs(Iv))*2) % Multiplied by 2 for single-sided spectrum
grid
xlabel('Frequency (Hz)')
ylabel('Amplitude (m/s^2)')
% Calculating PSD
N = length(D);
xdft = fft(D);
xdft = xdft(1:fix(N/2)+1); % Ensure xdft is correctly sliced for odd or even N
%%Modified code snippet%%
psd = (1/(Fs*N)) * abs(xdft).^2; % Correct power spectral density calculation
psd(2:end-1) = 2*psd(2:end-1); % Adjust for single-sided spectrum
% Plotting PSD
figure(3);
plot(Fv, 10*log10(psd))
grid on
title('Power Spectral Density Using FFT')
xlabel('Frequency (Hz)')
ylabel('Power/Frequency (dB/Hz)')
Ensure that your frequency vector and normalization factors are correctly applied for both the FFT and PSD plots for accurate spectral analysis.

Categorías

Más información sobre Spectral Measurements en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by