How do I generate a pulse train which starts at the origin using functions

Illustration
henryjames012 - 2021-02-24T09:41:49+00:00
Question: How do I generate a pulse train which starts at the origin using functions

How do I generate a pulse train which starts at the origin using functions in the Signal Processing Toolbox 6.10 (R2008b) ? I am trying to generate a train of rectangular pulses. I want the train to start at the origin (t=0) and would like to know how to do this using functions in Signal Processing Toolbox 6.10 (R2008b).  

Expert Answer

Profile picture of Prashant Kumar Prashant Kumar answered . 2025-11-20

his can be done using the PULSTRAN function in the Signal Processing Toolbox.
 
As mentioned in the Signal Processing Toolbox 6.10 (R2008b) documentation, the default 'rectpuls' function extends from -0.5 to 0.5. Additionally, the PULSTRAN function returns "func(t-d(1))+func(t-d(2)) +...", where 't' and 'd' are the time and delay vectors respectively. Thus, the number of "pulses" in the "train" will be the same as the number of elements in 'd'.
 
In order to generate pulses that do not overlap, the elements of 'd' must be greater than the pulse width (which is 1 by default for the 'rectpuls' function). Therefore, as an example, the first term should be "func(t-0.5)" so that the train of rectangular pulses starts at "t=0". In other words, the first element of 'd' must be half the width of the function (i.e. 'rectpuls') if the pulse train is to start at "t=0".
 
The following code is an example of how this can be implemented:
t=0:.01:10;   %Time vector 

w = 1; %pulse width

d= w/2:w*2:10; %delay vector

y2=pulstran(t,d,'rectpuls',w); 

plot(t,y2); 

set(gca,'Ylim',[-0.1 1.1]);


Not satisfied with the answer ?? ASK NOW

Get a Free Consultation or a Sample Assignment Review!