Mathematica Asked by RF_1 on July 24, 2021
I have a function as follows:
f[x_, t_] := x + t;
Table[{x, t, f[x, t]}, {x, 0, 1}, {t, 0, 2}]
When I write MatrixForm[%]
, I get
How to get a matrix as follows:
f[x_, t_] := x + t;
z = Table[{x, t, f[x, t]}, {x, 0, 1}, {t, 0, 2}];
There are several different formatting options, including the following. Note that the first two are presentation forms only; you can't do further operations on them. You can see this for yourself by applying Transpose to each of the three.
z1 = Flatten[z, 1];
TableForm[z1, TableHeadings -> {None, {"x", "t", "f(x,t)"}}]
z2 = Join[{{"x", "t", "f(x,t)"}}, Flatten[z, 1]];
Grid[z2, Frame -> All, ItemSize -> All]
Dataset[AssociationThread[First@z2, #] & /@ Rest@z2]
(credit to @creidhne from Better way to create a Dataset?)
Correct answer by theorist on July 24, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP