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 19:19:05 +0200
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20120907 Thunderbird/15.0.1

Doug Stewart skrev 2012-10-06 19:08:


On Sat, Oct 6, 2012 at 12:50 PM, Sergei Steshenko <address@hidden> wrote:




----- Original Message -----
> From: Torbjörn Rathsman <address@hidden>
> To: Sergei Steshenko <address@hidden>
> Cc: "address@hidden" <address@hidden>
> Sent: Saturday, October 6, 2012 5:28 PM
> Subject: Re: Real-data DFT in Octave
>
> Sergei Steshenko skrev 2012-10-06 15:35:
>>
>>
>>
>>  ----- Original Message -----
>>>  From: Torbjörn Rathsman <address@hidden>
>>>  To: address@hidden
>>>  Cc:
>>>  Sent: Saturday, October 6, 2012 3:18 PM
>>>  Subject: Real-data DFT in Octave
>>>
>>>  Is it possible to without much effort call the real to complex dft
> routins from
>>>  octave. It is easier to manipulate the spectrum that way, since i am
> guarantied
>>>  that the mirror part becomes correct. The purpose in this case is to
> compute
>>>  filtered derivative of second order.
>>>  _______________________________________________
>>>  Help-octave mailing list
>>>  address@hidden
>>>  https://mailman.cae.wisc.edu/listinfo/help-octave
>>
>>  I am not sure what the problem is, but dealing with real input data I use
> 'conj' and 'fliplr' in the end when I need to produce mirrored
> spoectrum for inverse FFT.
>>
>>  Regards,
>>     Sergei.
>>
>>
> Do you mean
>
>     Y=fft(y)';
>     for k=1:length(Y)
>         if(k<=1024)
>             Y(k)=(k-1)*(k-1)*Y(k)/N;
>         else
>             Y(k)=0;
>         end
>     end
>
>     Y=Y+conj( fliplr(Y) );
> ? cannot get it work.


Let's for simplicity assume N is even and let's assume 'signal' is 1:N real vector. Let's also assume 'filter' is 1:N/2 complex vector. Then:

spectrum = fft(signal);
filtered_spectrum = spectrum(1:N/2) .* filter;
filtered_signal = real(ifft([filtered_spectrum conj(fliplr(filtered_spectrum))]));

- the above is the idiom I'm using everywhere for real input signals.

Regards,
  Sergei.







>
_______________________________________________
Help-octave mailing list
address@hidden
https://mailman.cae.wisc.edu/listinfo/help-octave

To help us understand each other, I have a question.
Do you understand that the N/2 up to N results from the FFT are really the negative frequency results?
Yes. And for real input it is exacly the same but cojugated. FFTW claims that it can improve performance by taking advantage of this property: http://www.fftw.org/fftw3_doc/One_002dDimensional-DFTs-of-Real-Data.html#One_002dDimensional-DFTs-of-Real-Data

reply via email to

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