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 20:25:13 +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: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));

Attachment: reim.png
Description: PNG image


reply via email to

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