1
$\begingroup$

I have generated a Table in 3 dimensions, for two variables x, y.

grid = {{{1, 1}, {0, 1}, {0, 2}, {0, 3}, {0, 4}, {0, 5}}, {{1, 0}, {1, 
   1}, {1, 2}, {1, 3}, {1, 4}, {1, 5}}, {{2, 0}, {2, 1}, {2, 2}, {2, 
   3}, {2, 4}, {2, 5}}, {{3, 0}, {3, 1}, {3, 2}, {3, 3}, {3, 4}, {3, 
   5}}, {{4, 0}, {4, 1}, {4, 2}, {4, 3}, {4, 4}, {4, 5}}}

and I have computed values for each point using Map[myFunction[#[[1]], #[[2]]] &, grid, {2}], which has given me

myOutput = {{-3.8627*10^-23, 0.000246833, 3.08541*10^-8, 2.57117*10^-12, 
  1.60698*10^-16, 8.03492*10^-21}, {0., -3.8627*10^-23, 0., 0., 0., 
  0.}, {0., 0., 0., 0., 0., 0.}, {-1.8303*10^-26, 0., 0., 0., 0., 
  0.}, {0., 0., 0., 0., 0., 0.}}

I have the grid in Dimensions {5,6,2} and my values in Dimensions {5,6}. I would like to have a plain but readable table that has one one axis one dimension of the grid, on the other the other dimension, and the table cells containing the function values. Basically a ListPlot3d, but not as a plot, but with numbers. How can I achieve that?

$\endgroup$
  • $\begingroup$ Isn't MatrixPlot[ ] or ArrayPlot[ ] what you're after? $\endgroup$ – Dr. belisarius Sep 25 '15 at 15:02
  • $\begingroup$ Or even Grid[ ] $\endgroup$ – Dr. belisarius Sep 25 '15 at 15:03
  • $\begingroup$ @belisarius MatrixPlot and Grid both are almost there, but I can't find a way to add the grid (the coordinates from grid) to the picture. $\endgroup$ – FooBar Sep 25 '15 at 15:18
  • $\begingroup$ Well you don't really have a grid: some coordinates are missing (e.g., (0,0)), and others are duplicated. (e.g., (1,1)). $\endgroup$ – Alan Sep 25 '15 at 15:27
  • $\begingroup$ @Alan my calculations are not valid on the (0,0) point, so that was my quick-and-dirty solution to that. If this is an issue, feel free to replace the first (1,1) with (0,0) again. $\endgroup$ – FooBar Sep 25 '15 at 15:28
3
$\begingroup$
grid = Flatten[grid, 1]
myOutput = Flatten[myOutput, 1]
stubs = Sort@DeleteDuplicates[Map[First, grid]]
headers = Sort@DeleteDuplicates[Map[#[[2]] &, grid]]
MapThread[Rule, {grid, myOutput}]
Table[{i, j}, {i, stubs}, {j, headers}] /. % /. {_, _} -> Null
TableForm[%, TableHeadings -> {stubs, headers}]

enter image description here

$\endgroup$
2
$\begingroup$
TableForm[myOutput, TableHeadings -> {Range[0, i - 1], Range[0, j - 1]}]

Mathematica graphics

$\endgroup$

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.