function a=buildsignal()
  j=0
  for i=-1:0.1:3
    j=j+1
    if i<0
      a(j)=0
  elseif (i>=1)
    a(j) = 0
  else 
    a(j)=1
end
end
endfunction

function u=upwind(u,a,dt,dx,iter)
  n=length(u)
  plot2d([1:n],u,style=1)
  for i=1:iter
    tmp(1)=u(1)-a*(u(1)-u(n))/dx*dt
    
    for j=2:n
      tmp(j)=u(j)-a*(u(j)-u(j-1))/dx*dt
    end
  u=tmp
end
  plot2d([1:n],u,style=2)
endfunction
