spectral analysis of time versus signal data using FFT
13 ビュー (過去 30 日間)
古いコメントを表示
Hi, I have data for time (x) and signal (y) which i've read into an matrix:
time = squeeze(input(1,:)); signal = squeeze(input(2,:));
How can I perform a FFT on this matix data?
0 件のコメント
採用された回答
Wayne King
2012 年 6 月 21 日
It looks like from your squeeze() commands that time and signal are both just row vectors: 1xN
Do you really have a matrix here?
If signal is just a row vector (or column), then just
signalDFT = fft(signal);
gives you the discrete Fourier transform.
If you use fft() on a matrix, it will naturally take the DFT of each column. You don't want to take the Fourier transform of the time vector, that is not going to give you anything useful.
If you really want a time-frequency analysis (spectral information with some time localization), then use spectrogram on the signal vector.
その他の回答 (2 件)
Wayne King
2012 年 6 月 21 日
You don't need to specify N as an input to fft()
Fs = 2;
Y = fft(signal);
Pyy = abs(Y).^2/length(signal);
For the odd length input, make your frequency vector:
freq = 0:Fs/length(x):Fs/2;
Pyy = Pyy(1:round(length(signal)/2));
plot(freq,10*log10(Pyy))
xlabel('Hz'); ylabel('dB/Hz');
Do you have the Signal Processing Toolbox? If so you can just do:
[Pxx,F] = periodogram(signal,[],length(signal),2);
plot(F,10*log10(Pxx))
0 件のコメント
Muhammad Zeeshan Ahmed Khan
2022 年 1 月 3 日
TRY THESE OPTIONS
rng('default')
fs = 256; % sample frequency (Hz)
t = 0:1/fs:10-1/fs; % 10 second span time vector
x = Q1data;
y = fft(x);
n = length(x); % number of samples
f = (0:n-1)*(fs/n); % frequency range
power = abs(y).^2/n; % power of the DFT
figure;
plot(f,power)
xlabel('Frequency')
ylabel('Power')
y0 = fftshift(y); % shift y values
f0 = (-n/2:n/2-1)*(fs/n); % 0-centered frequency range
power0 = abs(y0).^2/n; % 0-centered power
figure;
plot(f0,power0)
xlabel('Frequency')
ylabel('Power')
m = length(Q1data); % original sample length
n = pow2(nextpow2(m)); % transform length
y = fft(Q1data,n); % DFT of signal
f = (0:n-1)*(fs/n)/10;
power = abs(y).^2/n;
figure;
plot(f(1:floor(n/2)),power(1:floor(n/2)))
xlabel('Frequency')
ylabel('Power')
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Spectral Measurements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!