[Top][All Lists]

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

fftshift bug?

From: Daryl Lee
Subject: fftshift bug?
Date: Sun, 3 Jul 2011 17:51:50 -0600

I'm plowing through the new book "GNU Octave Beginner's Guide" and I finally 
get to a concept I recall from graduate school--Fourier Analysis.  In the 
process, I discovered what I took to be a bug in the fftshift function, fixed 
it, and now I don't know what to do with what I found.

My environment: Octave 3.4.0, Mac OSX.

How to reproduce the bug:
>> fftshift([1 2 3 4])

ans =
  3 4 1 2

error: fftshift: A(I): index out of bounds; value 150 out of bound 1
error: called from:
 at line 70, column 14

So I opened fftshift.m and found this sequence:
    if (isvector (x))
      x = length (x);
      xx = ceil (x/2);
      retval = x([xx+1:x 1:xx]);

I replaced this with
    if (isvector (x))
      X = length (x);
      xx = ceil (X/2);
      retval = x([xx+1:X, 1:xx]);
(I just up-cased selected occurrences of "x") and all is well.

But since I'm just getting started, I'm not sure if it's just my ignorance.  
Could someone either confirm this or correct me?

Daryl Lee
Senior Software Engineer

reply via email to

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