Plotting impulse functions on the same time axis with other functions in MATLAB
The use of logical operators is not correct. A more generic verison is:

timeStart = -3; timeStop = 2; nSample = 1000;
time = linspace(timeStart,timeStop,nSample);
timeUp = 0; timeDown = 1; 
data = zeros(size(time));
data((time&gt;=timeUp) &amp; (time&lt;=timeDown)) = 1;
plot(time,data,'x-')