matrixFromFunction#
Create a matrix by evaluating a generating function at each index.
Available in: math cells, REPL.
Syntax#
matrixFromFunction(size, fn)
matrixFromFunction(size, fn, format)
matrixFromFunction(size, fn, format, datatype)
matrixFromFunction(size, format, fn)
matrixFromFunction(size, format, datatype, fn)
Arguments and behavior#
Pass row count, column count and a callback. Indices supplied to the callback are one-based in cell syntax.
Example#
Edit the inputs, then use Run or Reset. Changes stay in this example.
Example
f(I) = I[1] - I[2]
matrixFromFunction([3,3], f)Interactive examples could not load. You can still copy the expressions.
Expected result: matrix.