electronics forum

Rules | Recent posts | topic RSS | Search | Register  | Log in

Matlab truth


Post new topic  Reply to topic    EDAboard.com Forum Index -> Digital Signal Processing -> Matlab truth
Author Message
Aya2002



Joined: 12 Dec 2006
Posts: 1409
Helped: 254
Location: Iraq


Post12 Mar 2009 0:20   

ifft axis scaling matlab


Hi experts, i have a quistion here, please read the following paragragh as it is in a pdf document on the web:

The Fourier transform can be computed using the Matlab code
Fk = fft(fn)/N; % The FFT of the signal fn
fn = ifft(Fk)*N; % The Inverse FFT
ifft(fft(fn)); % This result = fn (within machine precision)

We must divide by the number of grid points N if we want to use the results of the FFT, because Matlab puts the normalization only in the inverse transform. As a result we must then multiply the IFFT by N to counter Matlab's dividing by N.

my doubt is: is the above is correct?

Thank you in advance.

Added after 3 hours:

any reply please
Back to top
Aya2002



Joined: 12 Dec 2006
Posts: 1409
Helped: 254
Location: Iraq


Post13 Mar 2009 16:14   

centeredfft


any help please?
Back to top
rramya



Joined: 14 Dec 2008
Posts: 76
Helped: 19


Post13 Mar 2009 20:35   

normalizing data matlab


Hi Aya2002,
I will wrtie some code & then i will conclude.

Tested without using normalisation factor (1/N):

time_signal=[ 1 2 3 4 3 2 ] ;
FFT_time_signal = fft(time_signal);
INVERSE_FFT_time_signal = ifft(FFT_time_signal );

o/p i got:
FFT_time_signal = 15 -4 0 -1 0 -4
INVERSE_FFT_time_signal = 1 2 3 4 3 2


Tested with using normalisation factor (1/N):

time_signal=[ 1 2 3 4 3 2 ] ;
FFT_time_signal = fft(time_signal)./length(time_signal);
INVERSE_FFT_time_signal = ifft(FFT_time_signal ).*length(time_signal);

FFT_time_signal = 2.5000 -0.6667 0 -0.1667 0 -0.6667
INVERSE_FFT_time_signal = 1.0000 2.0000 3.0000 4.0000 3.0000
2.0000

conclusion:
As per formula DFT does not use normalisation.
Instead IDFT uses normalisation factor (1/N) in the formula.
hence the matlab functon "fft" also operates as per formula does n't use normalisation factor (1/N) & "ifft" also operates as per formula uses normalisation factor (1/N) .


even without scaling we can get the same o/p.
what is the adv of using a scaling factor in fft and ifft???
i think one can think and get the answer for that.

I hope we will find it soon......

happy learning.
Back to top
Aya2002



Joined: 12 Dec 2006
Posts: 1409
Helped: 254
Location: Iraq


Post13 Mar 2009 21:48   

normalize data matlab


My Friend,

see my experement below:

x=ones(1,5)

x =

1 1 1 1 1

>> s=fft(x)

s =

5 0 0 0 0

>> ifft(s)

ans =

1 1 1 1 1

as shown above, Matlab did a complete conversion and inverse conversion with out need to do any normalization, I mean , that i do not need any normalization, while the Pdf file said that we must use the normalization. From which i conclude that this document is not correct.

Now, for your quiation "what is the adv of using a scaling factor in fft and ifft???", please see my answere below;

when we represent a signal within matlab, we usually use two vectors, one for the x-data and one for the y-data. The FFT command only operates on the y-data (converting the y-data from time domain to the frequency domain). So it is up to the user to determine what the x-data in the frequency domain will be!

Now let us to take an example:

y(t)=2cos( 2 Π fo t )
-------------------------

fo=4;
Fs=100;
Ts=1/Fs;
t=0:Ts:1-Ts;
n=length(t) ;
y=2*sin(2*pi*fo*t) ;
plot(t,y) ;

Matlab truth

when we take the fft of this curve, we would ideally expect to get the following spectrum in the frequency domain , we expect to see one peak of amplitude 1 at -4 Hz, and another peak of amplitude 1 at +4 Hz. So, let us use matlab's built in function fft to see the results.

yfr=fft(y) ;
stem(abs(yfr ) ) ;


Matlab truth

from the figure above, it does not quite look like what we predicted above. If we notice there are acouple of things that are missing:
1. The x-axis gives us no information on the frequency. How can we tell that the peaks are in the right place?

2. The amplitude is all the way up to 100.

3. The spectrum is not centered around zero.

To solve these problems, we must normalize the data and use the matlab function FFTshift after the function FFT as follows;

function [X freq]=centeredFFT(x,Fs)

N=length(x) ;
if mod(N,2) ==0
k=-N/2:N/2-1;
else
k=-(N/2)/2: (N-1)/2;
end
T=N/Fs;
freq=k/T; % The Frequency axis.
X=fft(x)/N; % Normalize the data.
X=fftshift(X); % shift the fft data so that it is centered.


the o/p of the above function will be correct frequency range and the transformed signal.

let's use this function in example:

[yfDom,frange]=centeredFFt(y,Fs);
stem(frange,abs(yfDom ) ) ;

Matlab truth

as we can see from the plot above, the information within the frequency spectrum is entirely symmetric.

Hope this is clear.

Montadar
Back to top
Google
AdSense
Google Adsense




Post13 Mar 2009 21:48   

Ads




Back to top
rramya



Joined: 14 Dec 2008
Posts: 76
Helped: 19


Post14 Mar 2009 19:34   

division by n affter fft in matlab


please see this site.

normally when we do fft(x) we get huge ampitude . we do scaling by dividing by N and while calculating inverse fft we also do scaling . if we do so, we cant satisfy parsevals theorem which maintains unitary between FFT & IFFT.
Also, the reason for why we scale fft basically????

all this answer were being discussed in the below mentioned site

pl see dicussion (between Matt and ramya )
http://www.mathworks.fr/matlabcentral/newsreader/view_thread/174066

also mainly this site:
http://www.mathworks.fr/matlabcentral/newsreader/view_thread/246628

See finally we got the answer.


Happy learning
Back to top
Aya2002



Joined: 12 Dec 2006
Posts: 1409
Helped: 254
Location: Iraq


Post14 Mar 2009 21:08   

frequency axis matlab fourier transform


many thanks friend and i hope to see you again in a good health after the surgery

good luck and G*D save you
Back to top
Arabic versionBulgarian versionCatalan versionCzech versionDanish versionGerman versionGreek versionEnglish versionSpanish versionFinnish versionFrench versionHindi versionCroatian versionIndonesian versionItalian versionHebrew versionJapanese versionKorean versionLithuanian versionLatvian versionDutch versionNorwegian versionPolish versionPortuguese versionRomanian versionRussian versionSlovak versionSlovenian versionSerbian versionSwedish versionTagalog versionUkrainian versionVietnamese versionChinese version
Post new topic  Reply to topic    EDAboard.com Forum Index -> Digital Signal Processing -> Matlab truth
Page 1 of 1 All times are GMT + 1 Hour
Similar topics:
Tool to generate truth table (2)
VHDL, Truth tables and Digital circuits, what to begin with? (2)
Sample the recorded sound in matlab...How ? Using MATLAB. (3)
How I use tektronix matlab waveform in MATLAB simulink? (2)
Matlab query, calculating threshold- need matlab code (1)
Matlab: using Matlab to model a wireless network (4)
MATLAB: how to link matlab with opnet (1)
PLL design with matlab Matlab (4)
matlab to C++ (7)
C or Matlab? (40)


Abuse || Administrator || Moderators || Support us || sitemap
topic RSS