Index-> contents reference index search Up-> SPT_HELP SignalGeneratorMain triwave Prev Next SPT_HELP-> SPTFunctionsByCategory Mathematical Functions Data Manipulation Functions SignalGeneratorMain AnalogFilterFunctions FIR Filter Design Window Functions IIR Filter Design FourierFunctions Plotting Functions Histogram Functions SignalGeneratorMain-> binbits nrzbits awgn cawgn ammod pmmod fmmod quadmod sinwave triwave sawwave sqrwave RandNumGens OtherSigGen triwave Headings-> Description Example

Create a TRIANGULAR Waveform
 Syntax `y = triwave(`fc,pc,fs,N`)` Syntax `y = triwave(`fc,pc,fs,N,M`)` Include: `include spt\triwave.oms` See Also sinwave , sqrwave , sawwave
``` ARGUMENTS:    INPUTS:      'fc'       = SCALAR, any numerical type. Center frequency [Hz]                   Coerced to DOUBLE for local processing.      'phase'    = SCALAR, any numerical type, Constant phase angle                   of carrier [radians]. Coerced to DOUBLE for                   local processing.      'fs'       = SCALAR, any numerical type. Sampling rate                   [Samples/second]. Coerced to DOUBLE for local                   processing.      'N'        = SCALAR, any numerical type. Requested row                   dimension (number of samples). Coerced to DOUBLE                   for local processing.      'M'        = SCALAR, any numerical type. Requested column                   dimension (optional). Coerced to DOUBLE for local                   processing.    RETURN: MATRIX, DOUBLE, each column being a sampled triangular            waveform with the requested parameters. ```
Description ``` ```This function generates samples from a triangularly shaped waveform. The frequency of the waveform in [Hz] is specified through argument 'fc'. An initial phase, expressed in [radians] is input via argument 'phase'. The sampling rate of the system is given through 'fs' in [Samples/second]. All of these may be of any numerical type and are all coerced to DOUBLE for local processing. The number of requested samples is given through argument 'N' and will be the row dimension of the returned matrix. If 'M' is included a matrix will be returned where each of M columns is an identical copy of the requested waveform. If 'M' is omitted a column vector is returned. ``` ```The returned waveform starts at zero for zero 'pc' and consists of samples taken from a waveform with peak value 1.0.

Example
Create two columns of 16 samples of 1 Hz of a triangular waveform samples at 16 Samples/second. ``` O>format double "f6.3" O>triwave(1,0,16,16,2) { [  0.000 ,  0.000 ] [  0.250 ,  0.250 ] [  0.500 ,  0.500 ] [  0.750 ,  0.750 ] [  1.000 ,  1.000 ] [  0.750 ,  0.750 ] [  0.500 ,  0.500 ] [  0.250 ,  0.250 ] [  0.000 ,  0.000 ] [ -0.250 , -0.250 ] [ -0.500 , -0.500 ] [ -0.750 , -0.750 ] [ -1.000 , -1.000 ] [ -0.750 , -0.750 ] [ -0.500 , -0.500 ] [ -0.250 , -0.250 ] ```