Azzera filtri
Azzera filtri

角速度のデータに対し​てFFTし、信号の周​波数スペクトルを解析​、ノイズの周波数範囲​を特定、カットオフ周​波数の決定をしたい。​このコードが合ってい​るか、またコードの追​加・改善。

4 visualizzazioni (ultimi 30 giorni)
ふた
ふた il 5 Giu 2024
Commentato: ふた il 11 Giu 2024
% Load the data
data = xlsread('ho130Gyrox.xlsx');
% FFT of data
N = length(data); % Length of data
Fs = 2000; % Sampling frequency
Y = fft(data); % FFT
Y_abs = abs(Y);
frequencies = (0:N-1)*(Fs/N)/1000; % Frequency axis
% Plot
figure;
plot(frequencies(1:N/2), Y_abs(1:N/2));
xlabel('Frequency (kHz)');
ylabel('Power(dB)');
title('Data Frequency Spectrum');

Risposta accettata

Sudarsanan A K
Sudarsanan A K il 10 Giu 2024
Hi,
Your code is on the right track for performing an FFT on angular velocity data and analyzing the frequency spectrum of the signal. However, there are several improvements and additions you can make to enhance its accuracy and functionality. Notably, when displaying the power in decibels (dB), you need to properly scale the FFT result before converting it to dB. Additionally, identifying the noise frequency range and determining the cutoff frequency requires further steps.
Here's an example code with some improvements and additional explanations:
% Load the data
data = xlsread('ho130Gyrox.xlsx');
% FFT of data
N = length(data); % Length of data
Fs = 2000; % Sampling frequency
dt = 1/Fs; % Time per sample
Y = fft(data); % FFT
Y_abs = abs(Y/N); % Normalize FFT result to scale it properly
Y_db = 20*log10(Y_abs); % Convert amplitude spectrum to dB
% Generate frequency axis
frequencies = (0:N-1)*(Fs/N)/1000; % Frequency axis in kHz
% Plot
figure;
plot(frequencies(1:N/2), Y_db(1:N/2));
xlabel('Frequency (kHz)');
ylabel('Power (dB)');
title('Data Frequency Spectrum');
% Identify noise frequency range and determine cutoff frequency
% This step depends on your specific data and noise characteristics
% For example, if noise is identified above 300 Hz, set cutoff frequency
cutoff_freq = 300; % Example cutoff frequency in Hz
cutoff_index = cutoff_freq/(Fs/N); % Find corresponding index in FFT result
% Display cutoff frequency on plot for visualization
hold on;
line([cutoff_freq/1000, cutoff_freq/1000], ylim, 'Color', 'red', 'LineStyle', '--');
legend('Frequency Spectrum', 'Cutoff Frequency');
Improvements and Additions:
  • FFT Scaling: The FFT result is divided by the length of the data N to correctly scale the amplitude. This ensures that the FFT magnitude does not depend on the length of the data.
  • Power in Decibels: The amplitude spectrum is converted into decibels to better represent the dynamic range.
  • Visualizing Cutoff Frequency: Adding a specific cutoff frequency to the plot helps visually identify which frequency components to filter out for noise reduction. However, the actual cutoff frequency should be selected based on the analysis of your data.
I hope this helps!
  1 Commento
ふた
ふた il 11 Giu 2024
ご回答ありがとうございます。実際のところ、静的での計測結果なので、理想は0ですので、FFTした場合、0成分以外がノイズになると思うので、カットオフ周波数は、1~10Hz程度にしようと考えていますが、それでいいのですか?
このコードや回答は今後の動的テスト等で参考にさせていただきます。ありがとうございます。

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Fourier Analysis and Filtering in Help Center e File Exchange

Prodotti


Release

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by