i have doing fourier transform of sine wave. I am given amplitude 5v. but at the fft it not shows the 5v amplitude. so please help me.
Show older comments
f=128;
A=5;
t = 0:1:128;
x= A*sin(2*pi*f*t);
xDFT = fft(x); % take fourier transform of signal
F=0:64; % frequency for fft
subplot(3,1,2);
plot(F,abs(xDFT(1:length(xDFT)/2+1)));
Answers (1)
Azzi Abdelmalek
on 11 Feb 2014
Edited: Azzi Abdelmalek
on 11 Feb 2014
First, there is an error in your last line, because length(xDFT)/2 is not always an integer, use instead
Y=abs(xDFT(1:fix(numel(xDFT)/2)+1))
stem(F,Y)
Who told you that a signal and its fft have the same amplitude?
There is another problem, your signal has 128 as a frequency, and you are using 1 as a sample time, this is incorrect. Look at this
t = 0:1:128;
x= A*sin(2*pi*f*t);
plot(t,x)
% Is this a sine wave?
The correct way to do it is to calculate your fft in one period, with an appropriate sample time
f=128; %The frequency
A=5; % The amplitude
period=1/f; % the period
ts=period/100; % sample time
t = 0:ts:period % vector time
x= A*sin(2*pi*f*t); % your signal
subplot(2,1,1)
plot(t,x)
[wc,w0,a0,ak,bk,c0,ck]=get_harmonics(x,ts)
subplot(2,1,2)
stem(abs(ck))
You can get get_harmonics function from this link
1 Comment
Ganesh Vasekar
on 11 Feb 2014
Categories
Find more on Fourier Analysis and Filtering in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!