function y = initialwave(x0,L,T,x)
imax = length(x);

for i=1:imax
    if x(i)<=x0
        y(i)=0;
    elseif x(i)<=x0+L/2
        y(i)=T*(x(i)-x0);
    elseif x(i)<=x0+L
        y(i)=T*(L-x(i)+x0);
    else
        y(i)=0;
    end
end