Help with Fourier transform fft

23 ビュー (過去 30 日間)
aurc89
aurc89 2014 年 9 月 18 日
編集済み: Rick Rosson 2014 年 9 月 20 日
I need to use the matlab function 'fft' to perform a Fourier transform, but the problem is that it always gives me a double-sided signal, while I would like to have a one-side signal. I sometimes use this function :
function four=FourierDir(t,s,nu)
% number of points in the time domain
N=length(t);
Nf=length(nu);
% sampling step in the time domain
Dt=diff(t);
Dt(N)=Dt(N-1);
four=zeros(1,Nf);
for ii=1:Nf
four(ii)=sum(Dt.*s.*exp(-1i*2*pi.*t.*nu(ii)));
end;
Can you suggest me an equivalent one made with fft , given as input t, s and nu ? Thanks so much.
  2 件のコメント
Mikhail
Mikhail 2014 年 9 月 18 日
Please explain, what do you mean by double-sided signal and one-side signal
Rick Rosson
Rick Rosson 2014 年 9 月 19 日
編集済み: Rick Rosson 2014 年 9 月 20 日
The Discrete Fourier Transform of a real-valued signal is conjugate symmetric. The double-sided spectrum shows the spectrum as a function of both positive and negative frequencies on the range [-Fs/2,+Fs/2), whereas the single-sided spectrum shows the spectrum for positive frequencies only, on [0,+Fs/2).

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

採用された回答

Rick Rosson
Rick Rosson 2014 年 9 月 19 日
編集済み: Rick Rosson 2014 年 9 月 19 日
function [ X,f,t ] = mydft(x,Fs)
% Assumes x is an N x 1 column vector
% and Fs is the sampling rate.
N = size(x,1);
dt = 1/Fs;
t = dt*(0:N-1)';
dF = Fs/N;
f = dF*(0:N/2-1)';
X = fft(x)/N;
X = X(1:N/2);
X(2:end) = 2*X(2:end);
figure;
plot(f,abs(X));
end

その他の回答 (2 件)

Youssef  Khmou
Youssef Khmou 2014 年 9 月 18 日
Generally fft is two sided , you just need to truncate it :
F=f(1:floor(end/2));

Shravankumar P
Shravankumar P 2014 年 9 月 18 日

カテゴリ

Help Center および File ExchangeDiscrete Fourier and Cosine Transforms についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by