I have an approximate solution for the function u[x,t] using the semi-discretization method in time step. For example, I have u[x,ti] for all x and some ti. I want to plot a 3D figure for this function and I don't know how to plot it.

  • 3
    $\begingroup$ What does your "approximate solution" look like? $\endgroup$ – J. M.'s ennui Jul 10 '12 at 14:57
  • 1
    $\begingroup$ Hi Parnia, welcome to Mathematica.SE! Plot3D, ListPlot3D, and DiscretePlot3D come to mind. Did you perhaps try those? $\endgroup$ – Sjoerd C. de Vries Jul 10 '12 at 15:33

If I understand correctly instead of a function defined analytically:

f[x_, t_] := Sin[x^2 + t^2]

You have a set of curves resulting from a discrete variable, similarly to:

fset[x_] = f[x, #] & /@ (Range[100]/50)

enter image description here

I think the easiest way to plot this is to make 2nd variable discrete too and use ListPlot3D:

ListPlot3D[fset /@ (Range[100]/50),  ColorFunction -> "SouthwestColors", Mesh -> None]

enter image description here

Another way, "preserving" continuous definition of one variable and keeping the other discrete is to use ParametricPlot3D:

ParametricPlot3D[ Evaluate@Transpose[{ConstantArray[x, 100], Range[100]/50, 
    fset[x]}], {x, 0, 2}, PlotStyle -> Directive[Blue, Opacity[.5]], BoxRatios -> {1, 1, 1/2}]

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.