If you have signal processing toolbox, use pulstran
EDIT
Amp=1
Wd=0.07
sp=[1.2 2.4 3];
fr=[7 7 6];
spac_vect=cumsum(cell2mat(arrayfun(@(x,y) x*ones(1,y),sp,fr,'un',0)))
amp_vect=Amp*ones(1,numel(spac_vect))
t=linspace(0,max(spac_vect),1000)
d = [spac_vect;amp_vect]';
y = pulstran(t,d,'rectpuls',Wd);
plot(t,y)
Best Answer