Generates a linearly swept sine wave.
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. |
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.
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.
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.
(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.
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
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.