MATLAB: Shifting a Square Wave in Matlab

plottingshiftsquare wave

Hello,
I'm having trouble creating a square wave. I have created my square wave using the gensig function but now my goal is to shift the wave over 0.5 units to the left so that it reads 1 from 0 to 0.5.
Can anyone offer any solutions to this or give me advice?
Do I now have to use a different function?
Code:
[u,t]=gensig('square',0.5,5,0.001)
plot (t,u); axis([0 5 -2 2])

Best Answer

plot(t-0.5, u)