Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Use of FFT2/IFFT2 and FFTSHIFT/IFFTSHIFT to Obtain Proper Phase

338 views
Skip to first unread message

Jonathan

unread,
May 19, 2011, 8:36:02 AM5/19/11
to
Hi Everyone,

I'm currently trying to perform an IFFT2 on a 2D set of data. The data can be real or complex, but I'm starting with purely real 2D data. The 2D aperture is rectangular, with an even number of sample points in each dimension (e.g. 8 by 12). For some background information, the 2D data represents a complex near-field measurement and by taking the IFFT2 of this data, one can obtain the far-field of this near-field. The majority of work I've seen on 2D IFFT2's tend to ignore the phase of the transformed data. In my work, the magnitude and phase are equally relevant.

The data looks something like a raised rectangular plateau, with pre-padding added prior to the IFFT2 (I don't rely on MATLAB's padding). Matlab's IFFT2 (or FFT2) assumes the center of the domain is located at index (1,1). This is important for the problem I'm trying to solve since the transformed phase is very relevant to my work. Basically, what you need to do is shift the data around (using FFTSHIFT and IFFTSHIFT) such that the center of the data is located at index (1,1). In terms of antenna quantities (in case any antenna engineers are reading) this is akin to placing the phase reference at the center of the aperture.

An excellent description of this can be found here:
http://www.mshalin.com/blog/?p=467

The test case of the near-field data is real AND even along both planes of symmetry and as such I expect the imaginary part of the transformed data to be zero. If I shift the 8 by 12 data (centered in the array with padding) using ifftshift, I get the data split into four pieces of 4 by 6 and sent to each corner of the matrix, along with the padding (as expected). I assumed that this would place the phase center in the correct spot and then my transformed data would be purely real. Not so. Unfortunately I still see a sizable imaginary part.

After some monkeying around, I noticed that if my data is 7 by 11 or 9 by 13 (or any odd number of samples) this method works like a charm. Unfortunately, I am fixed to 8 x 12 so I'm unable to change the number of my data points.

If anyone can help me with this problem I would really appreciate it. In particular, I'd like to be able to take the 8 x 12 data set and shift it around properly such that it places the phase center at the middle of the aperture and I will obtain zero imaginary part of the transformed data.


Please see the code shown below:

% Even number of samples
H = zeros(24,24);
H(9:16,7:18) = 1;

% Transform data
H = ifftshift(H); % this places the phase center at the center of the data
T = fftshift(ifft2((H)));

subplot(2,2,1), surf(real(T)/max(max(abs(T)))); colorbar; colormap gray; shading interp; title('Real Part');
subplot(2,2,2), surf(imag(T)/max(max(abs(T)))); colorbar; colormap gray; shading interp; title('Imaginary Part');
subplot(2,2,3), surf(abs(T)/max(max(abs(T)))); colorbar; colormap gray; shading interp; title('Magnitude');
subplot(2,2,4), surf(angle(T)); colorbar; colormap gray; view(2); shading interp; title('Phase');

Matt J

unread,
May 19, 2011, 8:50:04 AM5/19/11
to
"Jonathan" wrote in message <ir32ri$aib$1...@newscl01ah.mathworks.com>...
> Hi Everyone,

>
> The test case of the near-field data is real AND even along both planes of symmetry and as such I expect the imaginary part of the transformed data to be zero.
=================

No, because you have even-sized arrays, the planes of symmetry do not intersect at any of your sample points. Therefore using ifftshift can't possibly put the symmetry origin at (1,1) or at any other discrete sample location.

You could consider using interp1, to resample your data so that the point of symmetry is sampled. Or, you could multiply the fftshift by exp(j*2*pi*offset) to account for the half-sample spacing offset from the origin of symmetry.

Jonathan

unread,
May 19, 2011, 9:19:02 AM5/19/11
to
Hi, thanks for your comment.

I can see how to accomplish this with the interp function (in my case interp2). Thank you for the suggestion.

The simpler approach seems to be phase shifting the data using a complex exponential like you suggested. Since I have a 2D array, do you have a suggestion as to how I can shift the data properly? I want to suggest shifting one dimension of the data at a time, but I'm not certain how to go about this...

Many thanks.


"Matt J" wrote in message <ir33ls$csg$1...@newscl01ah.mathworks.com>...

Matt J

unread,
May 19, 2011, 9:19:02 AM5/19/11
to
"Matt J" wrote in message <ir33ls$csg$1...@newscl01ah.mathworks.com>...
>
> You could consider using interp1, to resample your data so that the point of symmetry is sampled. Or, you could multiply the fftshift by exp(j*2*pi*offset) to account for the half-sample spacing offset from the origin of symmetry.
=====================

Sorry, what I really meant here is modulate (assuming a 1D ifft for now ) by
exp(j*pi*(0:N-1)/N), where N is the number of sample points

For example


>> x=[1 2 3 4 4 3 2 1] %symmetric across non-integer sample location 4.5

x =

1 2 3 4 4 3 2 1

>> ifft(ifftshift(x)) %gives significant imaginary result

ans =

Columns 1 through 6

2.5000 0.7286 - 0.3018i 0 0.0214 - 0.0518i 0 0.0214 + 0.0518i

Columns 7 through 8

0 0.7286 + 0.3018i

>> N=length(x); ifft(ifftshift(x)).*exp(j*pi*(0:N-1)/N) %gives real result up to round-off

ans =

Columns 1 through 6

2.5000 0.7886 0 0.0560 - 0.0000i 0 -0.0560 - 0.0000i

Columns 7 through 8

0 -0.7886 + 0.0000i

Matt J

unread,
May 19, 2011, 9:54:03 AM5/19/11
to
"Jonathan" wrote in message <ir35c6$i2j$1...@newscl01ah.mathworks.com>...

> Hi, thanks for your comment.
>
> I can see how to accomplish this with the interp function (in my case interp2). Thank you for the suggestion.
>
> The simpler approach seems to be phase shifting the data using a complex exponential like you suggested. Since I have a 2D array, do you have a suggestion as to how I can shift the data properly? I want to suggest shifting one dimension of the data at a time, but I'm not certain how to go about this...
=========================

The generalization from 1D to 2D is fairly straightforward from shift properties of IFFTs. Instead of modulating by

W(n) = exp(j*pi*(0:n-1)/n),

you instead modulate, for an mxn image, by

weights2D=W(m).'*W(n)

If you want to optimize the computation, you could multiply all the rows by W(m) and then all the columns by W(n) using BSXFUN.

0 new messages