|
Greg <heath@alumni.brown.edu> wrote in message <7bdc64ef-1a65-45b9-8f2e-82fd3c4bbfa2@h11g2000yqb.googlegroups.com>...
> On Jul 6, 4:47 pm, "guj " <gulatiaks...@gmail.com> wrote:
> > Greg <he...@alumni.brown.edu> wrote in message <e104f561-edaa-4505-84c2-cf6bcfb49...@s31g2000yqs.googlegroups.com>...
> > > On Jun 28, 12:33 pm, Greg <he...@alumni.brown.edu> wrote:
> > > > On Jun 27, 4:25 pm, "guj " <gulatiaks...@gmail.com> wrote:
> > > -----SNIP
> > > > function [XFT,XLS,NMSEFT,NMSELS] = DFTgh1(x,t,f)
> >
> > > > % function [XFT,XLS,NMSEFT,NMSELS] = DFTgh1(x,t,f)
> > > > %
> > > > % Modification of AJ Johnson's dft for nonuniform sampling
> > > > %
> > > > % Computes XFT (Discrete Fourier Transform) at frequencies
> > > > % given in f, given samples x taken at times t:
> > > > %
> > > > % XFT(f) = sum(k=1,N){ dts(k) *x(k) * exp(-2*pi*j*t(k)*f) }
> > > > % = W *(x.*dts)
> > > > %
> > > > % where dts is a symmetrized modification of diff(t).
> > > > %
> > > > % Also computes the Least-Squared-Error Spectrum at
> > > > % frequencies given in f, given samples x taken at
> > > > % times t:
> > > > %
> > > > % XLS(f) = (W'\x)./dfs;
> > > > %
> > > > % where dfs is a symmetrized modification of diff(f).
> > > > %
> > > > % NMSEFT is the normalized mean-square-error of reconstucting
> > > > % x from X using the Inverse Fourier Transform formula. If
> > > > % mean(x) = 0, then the MSE is unnormalized.
> >
> > > Correction:
> >
> > > If mean(x) = x, i.e., x is constant, then the MSE is unnormalized.
> >
> > > > % NMSELS is the normalized mean-square-error of reconstucting
> > > > % x from X using Least Squares. If mean(x) = 0, then the MSE
> > > > % is unnormalized.
> >
> > > Correction:
> >
> > > If mean(x) = x, i.e., x is constant, then the MSE is unnormalized.
> >
> > > > % For comparison with MATLAB'sFFTwhen the spacing is uniform,
> > > > % double the end values x(1) and x(end) and divide X by dt0 =
> > > > % mean(diff(t))
> >
> > > -----SNIP
> >
> > > Hope this helps.
> >
> > > Greg
> >
> > What are your comments on the code below:
> > FFT is giving the same result as DFT for Non uniform sampling.
>
> Both are inappropiarte for nonuniform sampling. See the above
> code where nonconstant dt is taken into account.
>
> > I am curious to know the difference between NDFT and DFT ...Notation
> >
> > clear
> > dt=.01;
> > N=101;
> > func=sin([0:N-1]/4);
>
> BETTER TO USE A COLUMN VECTOR
>
> > f=1/dt/N/2*[-N:2:N-2];
>
> INCORRECT FOR N ODD
>
> > figure(1)
> > clf
> > subplot(3,1,1)
> > plot(dt*[0:N-1],func)
> > subplot(3,1,2)
> > plot(f,fftshift(abs(fft(func))))
>
> DIVIDE BY N TO GET CORRECT SCALE
>
> > k=1:N;
> > n=1:N;
> > DFT=exp(-i*2*pi*((k(:)-1)*(n-1)/N));
>
> POOR TERMINOLOGY CHANGE "DFT" TO "W"
>
> > subplot(3,1,3)
> > plot(f,fftshift(abs(DFT*func(:))))
> >
> > z=round(rand(1,N));
> > temp1=func;
> > temp2=z.*func;
> > lives=find(z~=0);
> > func=temp2(lives);
>
> POOR TERMINOLOGY. 50% DIMENSION REDUCTION.
> ==> CHANGE NAME OF SAMPLED FUNC TO FUNCZ
> HOWEVER, A 50% REDUCTION STILL LEAVES
> ~ 50 POINTS FOR 4 PERIODS OF FUNC.
> MUCH MORE INSTUCTIVE TO HAVE LESS
> THAN ~8 SAMPLES PER PERIOD. TRY A 2/3
> REDUCTION
>
> > DFT=DFT(:,lives);
> >
> > figure(2)
> > clf
> > subplot(3,1,1)
> > plot(dt*[0:N-1],temp1,dt*[0:N-1],temp2)
>
> NEED A PLOT OF FUNC AND FUNCZ
>
> > subplot(3,1,2)
> > plot(f,fftshift(abs(fft(temp2))))
> > subplot(3,1,3)
> > plot(f,fftshift(abs(DFT*func(:))))
> >
> > Here is NDFT, algorithm
> >
> > freq=(-N/2):(N/2-1);
>
> WHY IS df = 1?
> WHAT HAPPENS WHEN N is odd?
>
> >f_hat=a;
>
> WHAt IS a ???
>
> > f=zeros(M,1);
> > for k=1:N
> > f=f+f_hat(k).*exp(-2*pi*i*x*freq(k));
> > end;
> > So question is Which one is right for Non uniform sampling
>
> What are you comparing?
> The previous examples go from time to frequency
> Whereas your NDFT code goes from frequency to time.
> ????
>
> If the DFT and IDFT are to be approximations to the
> continuous time FT and IFT, the nonuniform differentials
> dt and df have to be taken into account.
>
> Go back to the code I posted (DFTgh1) to see how the nonuniform
> factors dt and df affect the calculation.
>
> In particular, the IDFT formula is not the inverse of
> the DFT formula, or vice versa, when either spacing is nonuniform!
>
> >..Is matlab DFT formula (which i have taken from help) is same
> > as FFT and can handle only fixed sample...
>
> The MATLAB formula, AS WELL AS YOUR NDFT, are only valid for
> uniform sampling.
>
> >what factor in DFT algorithm constraining it for fixed sampling.
>
> The lack of nonconstant dt. See the formula in DFTgh1
>
> > In DFT, algorithm we are multiplying our Coefficient with twiddle
> < factor, that twiddle factor is equally spaced ...is that the
> constrain...
> >
> > twiddle factor= exp(-2*pi*i*k*n/N)
>
> Yes. That is a special case for dt and df constant.
>
> The general form is W(k,n) = exp(-2*pi*i*f(k)*t(n))
>
>
> > ..IN this when we divide it by N, we only mean to normalise it..isnt
> > it..also 2pi is my sampling frequency ...
>
> ???
>
> > All these doubts are there because of the code which i have written above and i am dubious why its giving same result as fft ..Also what FFT do when it incur a irregular sampling....although it give wrong result but what is its working on such kind of input.
>
> Go back to the continuous time Fourier integral for a
> function that is zero outside of [0,T]. Then approximate
> the integral with a sum over N nonuniformly spaced samples.
> Notice that you cannot ignore the nonconstant differential
> dt. If you do it right, you should come up with something
> that looks like the formula in DFTgh1.
>
> Hope this helps.
>
> Greg
>
TRIVIAL Doubt :)
There are quite few number of algorithms which deals with application of FFT on irregular sample data points .........
So Mathematician start these with a complex sequence u_p p=-N:N and a set of arbitary points x_j j=0...2N-1, a straight forward exact evaluation of the sum
u(x) = sum{p=-N:N} u_p e ^(i p x) for x=x0,x1,......x2N-1
So we are basically evaluating polynomial at set of points which are not fixed (i;e x)......and we can invert it later to get it back. (They dont assume space domain or frequency domain)
My question is when we talk in term of Engineering language, here x is the time domain for me and p is frequency domain. Whole point is!
if i apply above on my signal which is sampled irregularly in time domain, i will get the spectra in frequency domain on inverting it back i will be back in time domain (Am i right)
if i am right then i dont understand why we take summation over time when we want to go from time domain to frequency domain, like from going to time domain to frequency domain my summation should be from x=o to 2N-1........
I really didnt get mathmatician ways, rnt they r going from equispaced points to non equispaced points...WELL some body plz clear my doubts ...
|