From: Matt J on 12 Jan 2010 17:41 "zhiliang liu" <uestclzl(a)163.com> wrote in message <hiirgt$rgu$1(a)fred.mathworks.com>... > Yes, I see. The x_fft_sum is equal to x_sum times the length of data (100 in the above code). But would you like to explain further how to explain the relationship. =============== It just has to do with how different technical professions have different global scaling conventions for DFTs. MATLAB uses the scaling conventions most popular among engineers. The DFT and IDFT formulae required for Parseval's theorem to hold are N X(k) =1/sqrt(N) sum x(n)*exp(-j*2*pi*(k-1)*(n-1)/N), 1 <= k <= N. n=1 N x(n) = 1/sqrt(N) sum X(k)*exp( j*2*pi*(k-1)*(n-1)/N), 1 <= n <= N. k=1 However, if you look instead at the "help fft" documentation, you will see that the formulae that MATLAB uses differs from the above by a factor of 1/sqrt(N) in the IDFT and sqrt(N) in the DFT: N X(k) = sum x(n)*exp(-j*2*pi*(k-1)*(n-1)/N), 1 <= k <= N. n=1 N x(n) = (1/N) sum X(k)*exp( j*2*pi*(k-1)*(n-1)/N), 1 <= n <= N. k=1
From: zhiliang liu on 12 Jan 2010 17:47 "Wayne King" <wmkingty(a)gmail.com> wrote in message <hiis5g$8ju$1(a)fred.mathworks.com>... > "zhiliang liu" <uestclzl(a)163.com> wrote in message <hiirgt$rgu$1(a)fred.mathworks.com>... > > TideMan <mulgor(a)gmail.com> wrote in message <320c9cc3-b21a-4c3b-b64f-65d202d7e244(a)26g2000yqo.googlegroups.com>... > > > On Jan 13, 9:10 am, "zhiliang liu" <uestc...(a)163.com> wrote: > > > > I typed the following codes, but why were the results i got not equal? > > > > > > > > >> t=[1:100]; > > > > >> x=sin(t); > > > > >> x_fft=fft(x); > > > > >> x_sum=sum(x.^2) > > > > > > > > x_sum = > > > > > > > > 50.2684 > > > > > > > > >> x_fft_sum=sum(abs(x_fft).^2) > > > > > > > > x_fft_sum = > > > > > > > > 5.0268e+003 > > > > > > Well, there is a hundred-fold difference between these results, and > > > you have exactly 100 data. Do you think there may be some correlation > > > here? > > > Try the same thing with t=[1:200]; and see what happens. > > > > Yes, I see. The x_fft_sum is equal to x_sum times the length of data (100 in the above code). But would you like to explain further how to explain the relationship. > > Hi, I think that both Tideman and I explained it to you. Look at the Wikipedia article on Parseval's theorem: > http://en.wikipedia.org/wiki/Parseval's_theorem > > and then look for the discrete Fourier transform you will see the squared norm equivalence. > > Wayne Got it. And I recalled that the examples in ‘help fft’. Some of the codes are given: --------------------------------- Y = fft(y, NFFT)/L; f = Fs/2*linspace(0,1,NFFT/2); % Plot single-sided amplitude spectrum. plot(f,2*abs(Y(1:NFFT/2))) --------------------------------- Y is given after divided by L, which refers to the length of data. Why here is divided by L, but not sqrt (L)?
From: Matt J on 12 Jan 2010 17:59 "zhiliang liu" <uestclzl(a)163.com> wrote in message <hiiu56$fcr$1(a)fred.mathworks.com>... > Got it. And I recalled that the examples in ‘help fft’. Some of the codes are given: > --------------------------------- > Y = fft(y, NFFT)/L; > f = Fs/2*linspace(0,1,NFFT/2); > % Plot single-sided amplitude spectrum. > plot(f,2*abs(Y(1:NFFT/2))) > --------------------------------- > Y is given after divided by L, which refers to the length of data. Why here is divided by L, but not sqrt (L)? The division by L here is not to satisfy Parseval. The programmer desired to use the fft to approximate the continuous Fourier transform under the assumption that the signal samples in y were taken at intervals of dt=1/L.
From: Greg Heath on 13 Jan 2010 01:39 On Jan 12, 5:47 pm, "zhiliang liu" <uestc...(a)163.com> wrote: > "Wayne King" <wmkin...(a)gmail.com> wrote in message <hiis5g$8j...(a)fred.mathworks.com>... > > "zhiliang liu" <uestc...(a)163.com> wrote in message <hiirgt$rg...(a)fred.mathworks.com>... > > > TideMan <mul...(a)gmail.com> wrote in message <320c9cc3-b21a-4c3b-b64f-65d202d7e...(a)26g2000yqo.googlegroups.com>... > > > > On Jan 13, 9:10 am, "zhiliang liu" <uestc...(a)163.com> wrote: > > > > > I typed the following codes, but why were the results i got not equal? > > > > > > >> t=[1:100]; > > > > > >> x=sin(t); > > > > > >> x_fft=fft(x); > > > > > >> x_sum=sum(x.^2) > > > > > > x_sum = > > > > > > 50.2684 > > > > > > >> x_fft_sum=sum(abs(x_fft).^2) > > > > > > x_fft_sum = > > > > > > 5.0268e+003 > > > > > Well, there is a hundred-fold difference between these results, and > > > > you have exactly 100 data. Do you think there may be some correlation > > > > here? > > > > Try the same thing with t=[1:200]; and see what happens. > > > > Yes, I see. The x_fft_sum is equal to x_sum times the length of data (100 in the above code). But would you like to explain further how to explain the relationship. > > > Hi, I think that both Tideman and I explained it to you. Look at the Wikipedia article on Parseval's theorem: > >http://en.wikipedia.org/wiki/Parseval's_theorem > > > and then look for the discrete Fourier transform you will see the squared norm equivalence. > > > Wayne > > Got it. And I recalled that the examples in ‘help fft’. Some of the codes are given: > --------------------------------- > Y = fft(y, NFFT)/L; > f = Fs/2*linspace(0,1,NFFT/2); > % Plot single-sided amplitude spectrum. > plot(f,2*abs(Y(1:NFFT/2))) > --------------------------------- > Y is given after divided by L, which refers to the length of data. Why here is divided by L, but not sqrt (L)?- Plug in exp(i*2*pi*f0*t) and see what the transform is. Hope this helps. Greg
From: Greg Heath on 13 Jan 2010 01:48 On Jan 12, 3:10 pm, "zhiliang liu" <uestc...(a)163.com> wrote: > I typed the following codes, but why were the results i got not equal? > > >> t=[1:100]; > >> x=sin(t); > >> x_fft=fft(x); > >> x_sum=sum(x.^2) > > x_sum = > > 50.2684 > > >> x_fft_sum=sum(abs(x_fft).^2) > > x_fft_sum = > > 5.0268e+003 http://groups.google.com/group/comp.soft-sys.matlab/msg/2222327db2ea7f51?hl=en Hope this helps. Greg
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 Prev: need help with Savitzky-Golay filter Next: Guidata in GUI |