Declares one or more matrix data structures.
||Number of rows, or labels for rows; default
||Number of columns, or labels for columns; default
||Values for all the matrices; default
||Whether to modify (instead of redefining) existing structures (
||Information to be used by default to identify the matrices in output (
||Identifiers of the matrices|
||Values for each matrix|
||Number of decimal places for printing|
||Extra text associated with each identifier|
||Minimum value for the contents of each structure|
||Maximum value for the contents of each structure|
||Default format to use when the contents represent dates and times|
A matrix stores a set of numbers as a two-dimensional array indexed by rows and columns. For example, the array
1 2 3 4
5 6 7 8
9 10 11 12
is called a three-by-four matrix.
You use the
COLUMNS options to specify the size of the matrices that are being defined. The simplest way of doing this is to use scalars to define the numbers of rows and columns explicitly. Alternatively, you can set
COLUMNS) to a variate, text or pointer, whose length then defines the number of rows (or columns) and whose values will then be used as labels, for example when the matrix is printed. Finally, if you specify a factor, the number of levels defines the number of rows or columns and the labels if available, or otherwise the levels, are used for labelling.
Values can be supplied for the matrices using either the
VALUES option or the
VALUES parameter. The option defines a common value (or set of values) for all the matrices in the declaration, while the parameter allows them each to be given different values. With the option you must supply a list of values. With the parameter, however, you must give a list of identifiers of data structures of the appropriate mode; unnamed data structures are particularly useful for this. Thus, to declare the matrix above, we can put:
MATRIX [ROWS=3; COLUMNS=4] X;\
If both the option and the parameter are specified, the parameter takes precedence.
DECIMALS parameter can be used to define the number of decimal places that Genstat will use by default whenever the values of the matrix are printed. This applies to output either by
You can associate a text with each data structure by means of the parameter
EXTRA. This text is then used by many Genstat directives to give a fuller annotation of output.
MAXIMUM parameters allow you to define lower and upper limits on the values expected for any structure that stores numbers. Genstat then prints warnings if any values outside that range are assigned to the structure.
DREPRESENTATION parameter allows a scalar or a single-valued text to be specified for each matrix to indicate that the matrix stores dates and times, and to define a format to be used for these, by default, when they are printed; details are given in the description of the
If you are declaring any of the matrices for a second time, by default you will lose all its existing attributes and values. You can retain those that remain valid by setting option
IPRINT option can be set to specify how the matrices will be identified in output. If
IPRINT is not set, they will be identified in whatever way is usual for the section of output concerned. For example, the
IPRINT option of
Commands for: Data structures.
" Example MATR-1: Declaring a rectangular matrix" TEXT [VALUES=Beer,Lager,Orange] Drink VARIATE [VALUES=0.5,1.0] Quantity MATRIX [ROWS=Drink; COLUMNS=Quantity;\ VALUES=1.1,0.6,1.2,0.65,0.8,0.45] Cost PRINT Cost; DECIMALS=2