필터 지우기
필터 지우기

FFT of discrete time domain data

조회 수: 2 (최근 30일)
PK
PK 2011년 7월 4일
Hello,
I would appreciate if anyone could help me to figure out the following problem.
I have 512 samples, the samples are taken within 1 microseconds of time interval. I would like to see the signal from 6 microseconds to 5.17e-4 seconds in frequency domain.
I have already tried the following codes in MATLAB, but it only gives me the time-domain representation of signal.
T = 5.17e-4;
N=512;
t=linspace(6e-6,T,N);
X=fft(data);
X = X/N;
dt = t(2)-t(1);
fs=1/dt;
fn=fs/2;
f=linspace(0,fn,length(t)/2);
X1=X(1:length(t)/2);
X1=abs(X1);
plot(f,X1);
I look forward for your reply. Thanks.
  댓글 수: 2
Rick Rosson
Rick Rosson 2011년 7월 4일
1. Can you tell me the size of |data| and what type of signal it represents?
2. Why are you calling the |fft| function twice? Why not just once?
PK
PK 2011년 7월 6일
1. the size of the data is 512, and it represents discrete time domain continuous signal. That means the samples are taken after 6e-6 sec at each 1e-6 sec time interval.
2. the fft function is called only once at line 4
I have tried plot(abs(x)); it still does not work

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

답변 (2개)

Rick Rosson
Rick Rosson 2011년 7월 4일
figure;
plot(abs(X));
  댓글 수: 1
PK
PK 2011년 8월 16일
it does not work.

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


Rick Rosson
Rick Rosson 2011년 8월 18일
In the following code, I am assuming that data is predefined as a column vector of size N x 1. If it is a row vector of size 1 x N, then either transpose data or change the first line of the code to take the number of columns instead of the number of rows.
%%Number of samples:
N = size(data,1); % assumes data is an N x 1 column vector
%%Compute the time domain:
Fs = 1e6; % samples per second
dt = 1/Fs; % seconds
t = dt*(0:N-1)';
T = N*dt;
%%two-sided spectrum, centered on DC
X = fftshift(fft(data))/N;
%%Compute the frequency domain:
dF = Fs/N;
f = (-Fs/2:dF:Fs/2-dF)';
%%Plot the time domain signal:
figure;
plot(t,data);
%%Plot the magnitude response:
figure;
plot(f,abs(X));
HTH.
Best,
Rick

카테고리

Help CenterFile Exchange에서 Get Started with Signal Processing Toolbox에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by