title: grid stack of characteristic curves(lines)
body: <p>I want to be able to simulate a hyperbolic equation on characteristic curves (lines). I will start with a basic one. u_{t}+2u_{x}=u^{2} with initial data u(x,0)=cos(x). The solution is u(x,t)=cos(x-2t)/(1-t*cos(x-2t)) where the charackteristic curve is x=2*t+x_{0}. So the solution is defined on characteristics (method of characteristics). </p>
  
  <pre><code>x=zeros(10,5);
  u=zeros(10,5);
  x0=linspace(0,10,10);
  t=linspace(0,5,5);
  for i=1:length(x0)
      for j=1:length(t)
          x(i,j)=2*t(j)+x0(i);
          if t(j)*cos(x(i,j)-2*t(j))==1
              u(i,j)=0;
          else
              u(i,j)=cos(x(i,j)-2*t(j))/(1-t(j)*cos(x(i,j)-2*t(j)));
          end
      end
  end
  mesh(u)
  </code></pre>
  
  <p>Apperently, the grid of characteristic lines and rectangular grid do not fit eachother. How can I plot the solutions on characteristics?</p>