% Create an array that gives the correct omega values for all FFT elements (in 1D).
function omega = omega_array(N, dt)
% N = number of elements in array.
% dt = sample interval in the time domain.
% Units of omega are radians per unit time.
omega = [0:N/2, -ceil(N/2-1):-1] * (2*pi) / (N*dt);


% Example: Suppose we have 1MHz sampling. So dt = 1e-6s.
%octave:7> omega_array(10,1e-6)
%ans =
%
% Columns 1 through 6:
%
%   0.0000e+00   6.2832e+05   1.2566e+06   1.8850e+06   2.5133e+06   3.1416e+06
%
% Columns 7 through 10:
%
%  -2.5133e+06  -1.8850e+06  -1.2566e+06  -6.2832e+05
%
% Note that the Nyquist frequency is pi megaradians per second. If
% there is an odd number of elements, we lack the Nyquist frequency:
%octave:8> omega_array(9,1e-6)
%ans =
%
% Columns 1 through 6:
%
%   0.0000e+00   6.9813e+05   1.3963e+06   2.0944e+06   2.7925e+06  -2.7925e+06
%
% Columns 7 through 9:
%
%  -2.0944e+06  -1.3963e+06  -6.9813e+05
