Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

FFT matlab: wrong 0Hz frequency

Status
Not open for further replies.

roujhan

Newbie level 2
Joined
May 28, 2010
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,294
Hello

I want to use fft in MATLAB to analize some exprimental data saved as an excell file attached here as a doc file.
my code:

A=xlsread('Book.xls'); G=A'; x=G(2, : );
N=length(x);
F=[-N/2:N/2-1]/N;
X = abs(fft(x-mean(x),N))
X = fftshift(X);
plot(F,X)

But it plots a graph with a large 0Hz wrong component, my true frequency is about 395Hz and it is not shown in the plotted graph.
Please tell me what is wrong.

Any help would be appreciated.
 

JoannesPaulus

Advanced Member level 3
Joined
Mar 19, 2008
Messages
773
Helped
235
Reputation
470
Reaction score
134
Trophy points
1,323
Location
USA
Activity points
5,006
I do not see the large 0Hz component... did you zoom in? There are two tones (-fo and fo) in my plot. You also need to set the frequency axis according to your sampling frequency and length of the capture, not just F=[-N/2:N/2-1]/N;
 

fcfusion

Full Member level 4
Joined
Mar 6, 2010
Messages
207
Helped
43
Reputation
86
Reaction score
24
Trophy points
1,298
Activity points
2,826
The 0 Hz component shows probably because your signal has an average value different of zero.
 

roujhan

Newbie level 2
Joined
May 28, 2010
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,294
fcfusion said:
The 0 Hz component shows probably because your signal has an average value different of zero.

Hi, Thanks for your answers
But I subtract the mean value.
 

albbg

Advanced Member level 4
Joined
Nov 7, 2009
Messages
1,254
Helped
434
Reputation
868
Reaction score
389
Trophy points
1,363
Location
Italy
Activity points
9,478
Hi,

I tryed to analyze your data. You didn't specify the sampling time, however if the time data are in seconds I assume it is 4 us.
What I can see in the FFT is a large peak at roughly 500 Hz and other low amplitude peaks. No DC is present. There is no need to subctrat the mean value since it is already 0 (very close to).
Did you zoom the FFT window in a region close to the DC ? Possibly you saw the two peaks (-500 Hz, 500 Hz) very close one each other confusing them for a single peak.

I used this code (actually is Scilab code but it is very similar to Matlab):

========================================

Res = 50; // refers the power to 50 ohms resistors

f=(-(N/2-1):(N/2))/(N*tsamp); // N number of samples, tsamp sampling time

val = abs(fft(x));
val = fftshift(val);

val = val./length(f);
val = val./sqrt(2); // recover the amplitude from peak to RMS


PmW = 1000*val.^2/Res; // power in mW
PdBm = 10*log10(PmW); // power in dBm

==========================================

you can plot both PmW or PdBm versus f. Plotting dBm you will see more in detail the floor and the low amplitude peaks.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top