3.5.4.3 fftfreq

Description

Calculate frequencies for FFT results, the original result is time * data(0,n-1).

Syntax

vector fftfreq(double time, int n, int side = 1, int shift = 1)

Parameters

time

Sampling interval

n

Signal size

side

Define the output spectrum, 1 = one-sided (default), 2 = two-sided.

shift

Define whether to shift for two-sided. 0 = no shift, 1 = shift (default).

Return

Return frequencies, the size should be either n (for two-sided) or ceil((n+1)/2) (for one-sided).

Example

// Start with a new workbook
newbook;
 
// Import the signal data
string fname$ = system.path.program$ + "Samples\Signal Processing\fftfilter1.DAT";
impASC fname:=fname$;
 
// Compute the frequencies based on time data in column A
int nn = wks.col2.nRows;  // Signal data size          
double time = col(A)[2] - col(A)[1]; // Sampling interval
col(C) = fftfreq(time, nn); // One-sided
col(D) = fftfreq(time, nn, 2, 1); // Two-sided, shifted

See Also

fftc