GSWEEP

Purpose:

Generates a linearly swept sine wave.

Syntax:

GSWEEP(length, spacing, start, end)

(s, f) = GSWEEP(length, spacing, start, end)

length

-

An integer, the number of output samples.

spacing

-

A real, the sample interval.

start

-

Optional. A real, the starting frequency in Hertz. Defaults to 10.0.

end

-

Optional. A real, the ending frequency in Hertz. Defaults to 100.0.

Returns:

A series, a linearly swept sine wave.

 

(s, f) = GSWEEP(length, spacing, start, end) returns both the swept sine wave and the instantaneous frequency series.

Example:

W1: gsweep(1000, .001, 2, 200)

 

Creates a 1000 point linear swept sine wave with points spaced at an interval of 0.001 seconds (a sample rate of 1/.001 = 1000 Hz) starting at 2 Hz and ending at 200 Hz.

Example:

W2: spectrum(W1, 1024)

W3: specgram(W1, 128, 120, 512)

W4: demodfm(W1)

 

W2 displays the normalized FFT showing frequency information from 2 to 200 Hz. W3 displays the joint time-frequency plot of W1, clearly displaying the linear frequency ramp. W4 demodulates W1 to approximately recover the linear frequency ramp.

 

image\gsweeppic.gif

Example:

(s, f) = gsweep(1000, .001, 2, 200)

 

Same as the first example except variable s contains the swept sine wave and variable f contains the instantaneous frequency values.

Remarks:

GSWEEP returns a series that is a linear frequency sweep from the starting frequency to the ending frequency. To prevent aliasing, both the starting and ending frequencies must be less than 1/(2*spacing), the Nyquist frequency.

 

The sweep is created by calculating the sine of the integrated linear ramp:

 

s = sin(2*pi*integ(t)) 

 

where:

 

t = start..inc..end 

 

inc = (end - start) / length 

 

See MODFM to frequency modulate any series.

See Also:

DEMODFM

GSIN

INTEG

MODFM