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: Sergei Steshenko
Subject: Re: Real-data DFT in Octave
Date: Sat, 6 Oct 2012 11:47:03 -0700 (PDT)




----- 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.


>


reply via email to

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