I am simulating a partial differential equation and I would like to compare the results of Plot3D and listPlot3D. I have gotten the plot3D code to work (not included) however, I am struggling to get the listPlot3D code to run. Here is my latest attempt:
eq = {D[u[t, x], {t, 1}] + D[u[t, x], {x, 1}] == Cos[x],
u[0, x] == x^2, u[t, -10] == u[t, 10]};
sol = NDSolve[eq, u, {t, 0, 10}, {x, -10, 10}, MaxStepSize -> 0.1];
data = Table[ u[t, x] /. sol, {t, 0, 10}, {x, -10, 10}];
ListPlot3D[data, Mesh -> None, InterpolationOrder -> 0,
ColorFunction -> "Rainbow"]
But it produces a bunch of errors like:
Outer::normal: Nonatomic expression expected at position 2 in Outer[List,1.,{1.,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.,15.,16.,17.,18.,19.,20.,21.}].
The actual picture of the errors is below:
What is going wrong here?