fftmag

Description

Calculate magnitude from FFT complex result.

Syntax

vector fftmag(vector<complex> cx, int side = 1)

Parameters

cx

The FFT complex results

side

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

Return

Return magnitude.

Example

// Start with a new workbook
newbook;
 
// Import the signal data
string fname$ = system.path.program$ + "Samples\Signal Processing\fftfilter1.DAT";
impASC fname:=fname$;
 
// Define a range variable for input signal
range rSignal = col(2);
 
// Add two new columns to store the amplitude results (one-sided, two-sided)
worksheet -a 2;
 
// Set column labels to distinguish
col(C)[L]$ = "Magnitude";
col(C)[C]$ = "One-Sided";
 
col(D)[L]$ = "Magnitude";
col(D)[C]$ = "Two-Sided";
 
// First use fftc to get FFT complex result
// Then use fftmag to get magnitude in column C and D
col(C) = fftmag(fftc(rSignal));// One-Sided
col(D) = fftmag(fftc(rSignal), 2);// Two-Sided and shift

See Also

fftamp, fftc, windata