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!