y = pulstran(t,d,'func')
'gauspuls', for generating a Gaussian-modulated sinusoidal pulse
'rectpuls', for generating a sampled aperiodic rectangle
'tripuls', for generating a sampled aperiodic triangle
pulstran is evaluated length(d) times and returns the sum of the evaluations y = func(t-d(1)) + func(t-d(2)) + ...
The function is evaluated over the range of argument values specified in array t, after removing a scalar argument offset taken from the vector d. Note that func must be a vectorized function that can take an array t as an argument.
An optional gain factor may be applied to each delayed evaluation by specifying d as a two-column matrix, with the offset defined in column 1 and associated gain in column 2 of d. Note that a row vector will be interpreted as specifying delays only.
func(t-d(1),p1,p2,...) + func(t-d(2),p1,p2,...) + ...
pulstran(t,d,p,fs) generates a pulse train that is the sum of multiple delayed interpolations of the prototype pulse in vector p, sampled at the rate fs, where p spans the time interval [0,(length(p)-1)/fs], and its samples are identically 0 outside this interval. By default, linear interpolation is used for generating delays.
pulstran(...,'func') specifies alternative interpolation methods. See interp1 for a list of available methods.
This example generates an asymmetric sawtooth waveform with a repetition frequency of 3 Hz and a sawtooth width of 0.1 s. The signal length is 1 s and the sample rate is 1 kHz.
t = 0 : 1/1e3 : 1; % 1 kHz sample freq for 1 s d = 0 : 1/3 : 1; % 3 Hz repetition frequency y = pulstran(t,d,'tripuls',0.1,-1); plot(t,y) xlabel 'Time (s)', ylabel Waveform
This example generates a periodic Gaussian pulse signal at 10 kHz with 50% bandwidth. The pulse repetition frequency is 1 kHz, the sample rate is 50 kHz, and the pulse train length is 10 ms. The repetition amplitude should attenuate by 0.8 each time.
t = 0 : 1/50e3 : 10e-3; d = [0 : 1/1e3 : 10e-3 ; 0.8.^(0:10)]'; y = pulstran(t,d,'gauspuls',10e3,0.5); plot(t,y) xlabel 'Time (s)', ylabel 'Periodic Gaussian pulse'