3d plotting of a matrix



   How can I perform ``plot3d()'' of a matrix?
   I need to get the plot of a 3d-grid (surface) defined by a matrix in which
   elements represent Z-coordinates for 3d-grid nodes.
   I tried the way described below:

   M:MATRIX([1,2,3,4],[1,2,3,4],[1,2,3,4],[1,2,3,4])$
   plot3d(M[x][y],[x,1,4],[y,1,4],['grid,4,4]);

I think the easiest thing to do is to define a function f, which is
what you want to plot: ie f(x,y) == z where the z is what you want:

  f(x,y):=float(M[?round(x),?round(y)])$
  plot3d(f,[x,1,4],[y,1,4],['grid,4,4]);

then plot3d works ok.  The problem with putting random forms in as the
first argument of plot3d, is that plot3d evaluates its arguments,
[perhaps it should not but it does..].
And it is not happy evaluating ?round(x) until that has a value..
Note also while M[1][2] will work, M[1,2] will probably be more
efficient not that that matters too much here..