I need to store values of a function of x and y defined as f[x_, y_] := Sin[Pi*x/3]*Sin[Pi*y/3]
at the following points xval = {0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6, 6.5, 7, 7.5, 8, 8.5, 9, 9.5, 10, 10.5, 11, 11.5, 12, 12.5, 13, 13.5, 14, 14.5, 15};
, same for y.
I need it to be a matrix of dimensions {961,3}
, being the first two columns the values of X and Y and the third, the value of f(x,y) at said points.
I have tried to use outer as Outer[f, xval, yval];
, but it provides a result whose dimensions are {31, 31}
. Is there a way to reshape the dimensions or an alternative to Outer
which allows for the data to be stored as I need?
Clear[f, x, y]
, then define your function,(t = Table[{x, y, f[x, y]}, {x, 0.0, 15, 0.5}, {y, 0.0, 15, 0.5}] // Flatten[#, 1] &) // Dimensions
. Nowt
contains your data. $\endgroup$