i want to draw the evolution of a function in the time with ListPlot3D, the code is:
Clear[f0, fval, x, f]
f0[x_] = E^(-4 (x - 1)^2);
x[t_, x0_] = x0 + f0[x0] t;
f[t_, x0_] = f0[x0];
fval[t_] := Table[{x[t, x0], f[t, x0]}, {x0, -5, 3, 0.1}]
ListPlot3D[{Table[
Table[{x[t, x0], t, f[t, x0]}, {x0, -.5, 3, 1}], {t, 0, 2, 0.1}]}]
But mathematica give me the error "must be a valid array or a list of valid arrays"
Your nested Table
have extra layers of {}
around parts of it.
Change it to
ListPlot3D[Partition[Flatten[{Table[
Table[{x[t, x0], t, f[t, x0]}, {x0, -.5, 3, 1}], {t, 0, 2, 0.1}]}],3]]
which gets rid of ALL the extra {}
and then only puts back enough to wrap each triple in {}
There must be some reason why ListPlot3D
doesn't understand nested rows of triples.