How to obtain accurate fast fourier transformation
古いコメントを表示
Hi
I tried to extract the amplitude and frequency of a wave equation
but the values are not accurate.
For a given frequency w1=5 and amplitude A1=1,
I've obtained w1=49.805 and A1=0.933.
And for a given frequency w2=1 and amplitude A2=5
I've obtained w2=9.765 and A2=4.623
It looks like the frequency is about 10 times
higher (but still not exact) and the amplitudes is about
10% lower than the expected values.
To see this, run the script below.
So I hope someone has an idea of what I'm doing wrong.
Thanks
Emerson
clear all;
close all;
%Wave properties
A1=1; % Amplitude1 (dimensionless)
w1=5; % Frequency1 (Hz)
A2=5; % Amplitude2 (dimensionless)
w2=1; % Frequency2 (Hz)
% Time properties
Datapoints = 1000; % Number of recorded data;
Length=10; % Length (seconds);
Step= Length/Datapoints; % Fraction of seconds
t = (0:Datapoints-1)*Step; % Time vector
% Sum of a w1-Hz sinusoid and a w2-Hz sinusoid
y = A1*sin(2*pi*w1*t) + A2*sin(2*pi*w2*t);
% Fourier Transformation
NFFT = 2^nextpow2(Datapoints); % Next power of 2 from length of y
Y = fft(y,NFFT)/Datapoints;
f = Datapoints/2*linspace(0,1,NFFT/2+1);
% 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('Amplitude - |Y(f)|')
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Discrete Fourier and Cosine Transforms についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!