Return samples of the unit-amplitude rectangular pulse at the times indicated by t.
rectpuls(t, w =1)
Arguments
t: Sample times of unit rectangular pulse, specified by a vector.
w: Rectangle width, specified by a positive number. Default: 1
Returns
Rectangular pulse of unit amplitude, returned as a vector.
Details
y <- rectpuls(t) returns a continuous, aperiodic, unit-height rectangular pulse at the sample times indicated in array t, centered about t = 0.
y <- rectpuls(t, w) generates a rectangular pulse over the interval from -w/2 to w/2, sampled at times t. This is useful with the function pulstran for generating a series of pulses.
Examples
fs <-10e3t <- seq(-0.1,0.1,1/fs)w <-20e-3y <- rectpuls(t, w)plot(t, y, type="l", xlab ="Time", ylab ="Amplitude")fs <-11025# arbitrary sample ratef0 <-100# pulse train sample ratew <-0.3/f0 # pulse width 1/10th the distance between pulsesy <- pulstran (seq(0,4/f0,1/fs), seq(0,4/f0,1/f0),'rectpuls', w = w)plot (seq(0, length(y)-1)*1000/fs, y, type ="l", xlab ="Time (ms)", ylab ="Amplitude", main ="Rectangular pulse train of 3 ms pulses at 10 ms intervals")