フィルターのクリア

Confusion with FFT for a specific part of the whole signal

5 ビュー (過去 30 日間)
Ancalagon8
Ancalagon8 2017 年 2 月 4 日
コメント済み: Star Strider 2021 年 1 月 27 日
As a newbie i am working on a signal from an accelerometer and i am trying to produce an fft for a specific part of the whole signal. I am a little bit confused about which code for the fft is the appropriate to use for my case.
here is my code:
clear all
close all
load signal
tvec=noact(:,1);
acc=noact(:,2);
%% ALL SIGNAL
L=length(signal); % Length of signal
t_max=max(signal(:,1)); % Tmax
Fs=L/t_max; % Sampling Rate
T = 1/Fs; % Sample time
%% PART OF SIGNAL
trace1=signal(Fs*25:Fs*32,:); % select part of signal
matrice1=trace1(:,2); % accelerations column
L1=length(matrice1); % Length of trace (number of samples)
t1 = (0:L1-1)*T; % Time vector
% Frequency vector
f1=(0:Fs/length(matrice1):(length(matrice1)-1)*Fs/length(matrice1));
FrecSign=abs(fft(matrice1))*T;
figure
plot(FrecSign);
xlabel Frequency(Hz)
ylabel Amplitude
title 'FFT'
or
NFFT = 2^nextpow2(L); % Next power of 2 from length of matrice1
Y = fft(matrice1,NFFT)/L;
f = Fs/2*linspace(0,1,NFFT/2+1); % create frequency vector
figure % Plot single-sided amplitude spectrum.
plot(f,2*abs(Y(1:NFFT/2+1)))
title('Single-Sided Amplitude Spectrum of y(t)')
xlabel('Frequency (Hz)')
ylabel('|Y(f)|')
Thanks in advance

採用された回答

Star Strider
Star Strider 2017 年 2 月 4 日
I cannot follow our code.
However, you cannot ‘produce an fft for a specific part of the whole signal’, since you have to take the fft (link) of the entire signal if you want valid data.
If you want to view only part of the signal, use the axis function to limit the frequency (here x) axis to the range you want.
If you want to eliminate specific frequencies from your accelerometer signals (for example a constant offset, low-frequency baseline variations, high-frequency noise), use a discrete filter. There are several ways to to this, with the designfilt function being the easiest to use (in my opinion).
  8 件のコメント
Brad
Brad 2021 年 1 月 27 日
Hi Star
I have a question regarding your answer here, I would very much appreciate it if you answer my question.
Thank you
Brad
Star Strider
Star Strider 2021 年 1 月 27 日
Done!
And thank you for accepting it!

サインインしてコメントする。

その他の回答 (2 件)

Ancalagon8
Ancalagon8 2017 年 2 月 6 日
One last question. In [PSDx,fx] = periodogram(x,[],[],Fs,'power');
x should be
i) the original signal (acc over time)?
ii) the original signal (only the acc column)
iii) the fft?
Thanks in advance!
  1 件のコメント
Star Strider
Star Strider 2017 年 2 月 6 日
I’m not sufficiently certain that I understand your data well enough to address that. I would analyse one variable at a time in each call to periodogram, so most likely (ii).

サインインしてコメントする。


Ancalagon8
Ancalagon8 2017 年 2 月 6 日
So in order to produce a periodogram, my input x should be the acceleration vector.
  1 件のコメント
Star Strider
Star Strider 2017 年 2 月 6 日
Yes, if you want the periodogram of your acceleration data.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSpectral Measurements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by