SIGNAL Function

Computes a variety of standard signals, including a square wave, sine wave, cosine wave, sawtooth wave, random waves, and the periodic sinc or Dirichlet function.

Usage

result = SIGNAL(n, keyword)

Input Parameters

n—The number of values to compute. The parameter n must be greater than 2.

keyword—Exactly one keyword must be set to select the wave type.

Returned Value

result—A one-dimensional array containing the requested signal.

Keywords

Cosine—If present and nonzero, generates a wave using the cosine function.

Diric—If present and nonzero, generates a wave using the periodic sine or Dirichlet function.

Norm_random—If present and nonzero, generates a wave using a random normal distribution.

Periods—A scalar value specifying the number of periods to compute for the desired signal.

Sawtooth—If present and nonzero, generates a wave using the sawtooth function with period 2p. If Sawtooth is set to a value in the closed interval [0, 1], the peak of the wave occurs at (Sawtooth*2*!Pi). For example:

Sawtooth = 0.0, results in a pure sawtooth waveform (pulse up, ramp down).

Sawtooth = 0.5, results in a triangle waveform (ramp up, ramp down).

Sawtooth = 1.0, results in a pure ramp waveform (ramp up, pulse down).

Sine—If present and nonzero, generates a wave using the sine function.

Square—If present, generates a wave using the square function. The value of Square specifies the percent of the wave that is positive. Thus, setting Square = 0.5 results in a one-dimensional array in which (n +1)/2 elements are equal to 1, and n/2 elements are equal to –1.

Unif_random—If present and nonzero, generates a wave using a random uniform distribution.

Discussion

The standard definition of each keyword signal is used to compute the period of the desired signal. Specifically, for a given value of n, compute t, such that t = DINDGEN(n)/n.

The following definitions are used.

Sine wave—SIN(Periods*2p*t)

Cosine wave—COS(Periods*2p*t)

Random Uniform wave—RANDOM(n, /Uniform)

Random Normal wave—RANDOM(n, /Normal)

Square wave—A square wave with a maximum value of 1, and a minimum of –1. The value of the keyword Square defines the percent of the wave equal to 1.

Sawtooth wave—A sawtooth wave with an adjustable peak location based on the value of Sawtooth.

Periodic sinc, or Dirichlet wave—If t = 2*!Pi*k, then Diric = (–1)(k*n–1), otherwise  Diric = SIN(n*x/2) / (n*SIN(x/2).

Example

In this example, SIGNAL generates each of the seven types of signal plots. The results are shown in Signals Produced from SIGNAL.

!P.Multi = [0, 2, 4]
!P.Charsize = 2
n = 500
p = 3
PLOT, SIGNAL(n, /Sine, Periods = p), Title = 'Sine'
PLOT, SIGNAL(n, /Cosine, Periods = p), Title = 'Cosine'
PLOT, SIGNAL(n, Square = .75, Periods = p), Title = 'Square', $
YRange = [-1.5, 1.5]
PLOT, SIGNAL(n, Sawtooth = .25, Periods = p), Title = 'Sawtooth'
PLOT, SIGNAL(n, /Unif_random), Title = 'Random Uniform'
PLOT, SIGNAL(n, /Norm_random), Title = 'Random Normal'
PLOT, SIGNAL(n, Diric = 24, Periods = p), Title = $
'Periodic sinc, or Dirichlet'
; Seven plots are shown. The periodic signal plot (Sine, Cosine,
; Square, Sawtooth and Diric) each show three periods of signal
; by using Periods in the calling sequence.

 

Signals Produced from SIGNAL

See Also

SINC