help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Real-data DFT in Octave


From: Torbjörn Rathsman
Subject: Re: Real-data DFT in Octave
Date: Sat, 06 Oct 2012 21:05:23 +0200
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20120907 Thunderbird/15.0.1

Sergei Steshenko skrev 2012-10-06 20:47:



----- Original Message -----
From: Torbjörn Rathsman <address@hidden>
To: Sergei Steshenko <address@hidden>; "address@hidden" <address@hidden>
Cc:
Sent: Saturday, October 6, 2012 8:25 PM
Subject: Re: Real-data DFT in Octave

Sergei Steshenko skrev 2012-10-06 20:06:


  ----- Original Message -----
  From: Torbjörn Rathsman <address@hidden>
  To: Sergei Steshenko <address@hidden>
  Cc:
  Sent: Saturday, October 6, 2012 7:36 PM
  Subject: Re: Real-data DFT in Octave

  [snip]
  I get imaginary part that is in the same order of magnitude as the real
  part. Note: my N is odd, but that should only result in a discarded
  sample or?
  For odd N you do the following:

  1) leave (N+1)/2 frequency bin intact;
  2) take the first (N-1)/2 frequency bins and mirror them around (N+1)/2
frequency bin.
  In such a manner nothing is lost/discarded, everything is mathematically
strictly invertible.
  E.g. for N=5 you have in Octave terms:

  1 2 3 2' 1'

  where "'" means complex conjugate; since '1' is DC
1' == 1, but who cares, i.e. it's easier to write mirroring not taking
this into account - complex conjugate of a real component is still the same
real.
  Regards,
     Sergei.


Even N also gives me wrong result.

     Y=fft(y);
     length(y) %31047
     Y=Y(1:floor(length(Y)/2));
     length(Y) %15523
     for k=1:length(Y)
         if(k<=1024)
             Y(k)=(k-1)*(k-1)*Y(k)/N; %diffrentiate twice
         else
             Y(k)=0;
         end
     end
     Y=[Y; conj(flipud(Y))];
     y=ifft(y);
     plot(real(y),imag(y));

What are you trying to achieve ? If you have spectrum, why won't use it to 
calculate derivative ?


Regards,
   Sergei.


I am trying to apply a filter that is k*k for k<1024 which is somewhat equivalent to diffrentiate the input twice for low frequencies. Also I want to get rid of high frequency noise. However, the filter does not work

Now y is of even length:

    Y=fft(y);
    length(y)
    Y=Y(1:floor(length(Y)/2));
    length(Y)

    Y=[Y; conj(flipud(Y))];
    y=ifft(Y); %I missed capital Y here but
    plot(real(y),imag(y)); %still huge imaginary part.

Attachment: reim.png
Description: PNG image


reply via email to

[Prev in Thread] Current Thread [Next in Thread]