|
From: Greg Heath on 5 May 2008 09:32 On Apr 29, 11:57 am, "h xu" <quabla...(a)gmx.de> wrote: > i've written a small and simple script to test the > fft-function of matlab that transformates exp(i*n*pi/xmax * > x) from xmin=-xmax to xmax. that should result in a > kronecker delta with positive amplitude with value 1... but > for some reason the amplitude is negative for odd n,... why > is that? > > xmin=-5; xmin~=0 makes phase interpretation difficult > xmax = 5; > > N= 2^8; Too high; Try the 10 separate trials N = 3:12 > dx = (xmax-xmin)/N; Incorrect. See below > x = linspace(xmin,xmax,N); > > y= exp(3* i*pi/xmax *x); Weird function. Try an FFT basis function. See below -----SNIP close all, clear, clc, j=0 N = 8 % Instructive to look at ALL of N=3:12 xmin = -5 xmax = 5 dx = (xmax-xmin)/(N-1) X = N*dx % FFT imposed period = 10+dx x = linspace(xmin,xmax,N)'; % OK (just changed to column) x = xmin + dx*(0:N-1)' % Alternate form df = 1/X % frequency spacing f = df*(0:N-1)'; % The FFT basis functions are exp(2*pi*i*f(n)*x) f0 = (N/4)*df % Half of the Nyquist frequency y = exp(2*pi*i*f0*x); z = zeros(size(x)); j=j+1,figure(j) subplot(2,2,1), hold on plot(x,z,'k') plot(x,real(y)) subplot(2,2,2), hold on plot(x,z,'k') plot(x,imag(y)) subplot(2,2,3), hold on plot(x,abs(y)) axis([xmin xmax 0 2]) subplot(2,2,4), hold on plot(x,z,'k') plot(x,angle(y)) Y = dx*fft(y); y0 = df*Y; % Rescaling to the size of y j=j+1,figure(j) subplot(2,2,1), hold on plot(f,z,'k') plot(f,real(y0)) subplot(2,2,2), hold on plot(f,z,'k') plot(f,imag(y0)) subplot(2,2,3), hold on plot(f,abs(y0)) % axis([0 max(f) 0 1.1*max(abs(Y))]) % axis([0 max(f) 0 1.1*max(abs(Y))]) subplot(2,2,4), hold on plot(f,z,'k') plot(f,angle(y0)) Hope this helps. Greg
|
Pages: 1 Prev: surface integration using unsorted numerical data Next: xPC and display blocks |