필터 지우기
필터 지우기

fft

조회 수: 1 (최근 30일)
Aishanou
Aishanou 2011년 7월 5일
A very fundamental doubt... I have a a signal as a 2xN array. The first row contains the time instants at which samples have been taken and the second row contains the data values at those sampling instants. Now when i take the fft of the data values, how do i map the corresponding time values in frequency domain. As in, i wish to plot the fft vs frequeny. How do i obtain the frequency axis?
code which i have used
Fs=500; L=length(sym_signal); y=sym_signal(7,:); NFFT = 2^nextpow2(L); % Next power of 2 from length of y Y = fft(y,NFFT)/L; f = Fs/2*linspace(0,1,NFFT/2+1); plot(f(1:100),2*(abs(Y(1:100))));
The Fs which i have used is obtained by finding the reciprocal time interval between two consecutive time values. Is this the correct way of doing it?
  댓글 수: 3
Aishanou
Aishanou 2011년 7월 5일
Thanks...however my data is taken from experimental results and not generated as sinusoidal function(with or without noise) of time values. Yet, i got the answer for obtaining Fs. Thanks once again.
Ashish Uthama
Ashish Uthama 2011년 7월 6일
Please consider using a more descriptive title and formatting the code.
Are you saying that your sampling is not uniform? A naive approach might be to resample/interpolate the data to obtain uniform sampling (and thus, a constant Ts). This will introduce some artifacts, and I am sure there are better ways.

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

채택된 답변

Paulo Silva
Paulo Silva 2011년 7월 5일
%Your data 2xN
t=1:0.001:10;
data=[t;sin(2*pi*50*t)+2*randn(size(t))];
%notice the sin+noise, noise added just for fun
Ts = data(1,2)-data(1,1); % Sample time
Fs = 1/Ts; % Sampling frequency
L = numel(t); % Length of signal
y = data(2,:); % data from signal
plot(Fs*t(1:50),y(1:50))
title('Signal Corrupted with Zero-Mean Random Noise')
xlabel('time (milliseconds)')
NFFT = 2^nextpow2(L); % Next power of 2 from length of y
Y = fft(y,NFFT)/L;
f = Fs/2*linspace(0,1,NFFT/2+1);
figure %create another figure for the other plot
% 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)|')
  댓글 수: 2
Ashish Uthama
Ashish Uthama 2011년 7월 6일
Paulo, my guess is that the user has non-uniform sampling, or something like:
t =[ 1 2 3 5 6 8 10..]
Paulo Silva
Paulo Silva 2011년 7월 6일
in that case he just need to use the interp function

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by