Previous Up Next

6.44.4  Creating a matrix with a formula or function: makemat matrix

You can use a function or a formula to specify the elements of a matrix with the makemat or matrix command.


Example.
Input:

makemat((j,k)->j+k,4,3)

or:

h(j,k):=j+k
makemat(h,4,3)

Output:





012
123
234
345




Note that the indices are counted starting from 0.

The matrix command can be used similarly, but note that the arguments are given in a different order and the indices start at 1.
(matrix can also be used to turn tables into matrices; see Section 6.46.1.)


Examples.


Previous Up Next