Previous Up Next

14.2.4  Creating a matrix with a formula or function

Use a function or a formula to specify the elements of a matrix with the makemat or matrix command.

The matrix command can be used similarly, but note that the arguments are given in a different order and the indices start at 1. (See Section 14.4.2 for other uses of matrix.)

Examples

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

or:

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




012
123
234
345




          

Note that the indices are counted starting from 0.

matrix(2,3)
     


000
000


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

or:

h(j,k):=j+k:; matrix(4,3,h)
     




012
123
234
345




          

Previous Up Next