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

H
henryjames012 · Feb 24, 2021 · 2.5K views
Question
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 PhD Expert
Answered Aug 24, 2026
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]);
100% Run Guarantee 3-Hour Fast-Track Delivery

Need a Custom Version or Complete Simulation for This Problem?

Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.

Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here

Get a Free Consultation or a Sample Assignment Review!