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

조회 수: 11 (최근 30일)
ふた
ふた 2024년 6월 5일
댓글: ふた 2024년 6월 11일
% 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');

채택된 답변

Sudarsanan A K
Sudarsanan A K 2024년 6월 10일
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
ふた
ふた 2024년 6월 11일
ご回答ありがとうございます。実際のところ、静的での計測結果なので、理想は0ですので、FFTした場合、0成分以外がノイズになると思うので、カットオフ周波数は、1~10Hz程度にしようと考えていますが、それでいいのですか?
このコードや回答は今後の動的テスト等で参考にさせていただきます。ありがとうございます。

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by