Mat for Beginners: Difference between revisions

From BR Wiki
Jump to navigation Jump to search
 
(One intermediate revision by the same user not shown)
Line 39: Line 39:
  40
  40


Arrays can be sorted, which changes the order of the items contained within the arrays. For example, to sort an array of string constants:
Arrays can be sorted, which changes the order of the items contained within the arrays. For example, to sort an array in ascending order:


  AIDX(Mat A$)
  AIDX(Mat A)
 
returns
0
10
25
30
40


Arrays can also have more than one dimension.
Arrays can also have more than one dimension.
Line 50: Line 57:


These are easiest to picture like a spread sheet with the two numbers  identifying which cell a value is contained in (or like X and Y on a graph). Arrays can have up to 9 dimensions.
These are easiest to picture like a spread sheet with the two numbers  identifying which cell a value is contained in (or like X and Y on a graph). Arrays can have up to 9 dimensions.
See [[Mat]] for more details.


==See Also==
==See Also==

Latest revision as of 20:44, 23 January 2013

Mat (M) is short for matrix. A matrix is another word for an array. An array of variables in this case. An array is a series of variables.

Examples

Mat A would refer to the whole array of A(1) to A(10) (if 10 is the highest item in the array)

each item in the array can contain a different value. for example

A(1)=10
A(2)=30
A(3)=25
A(4)=40

A mat statement is refer to the whole array, for example:

PRINT MAT A

returns the following:

10
30
25
40

A mat statement can also be used to change how large the array is, for example:

MAT A(5)

changes the array to have 5 items in it. Then, after executing MAT A(5) and typing:

PRINT MAT A

you would get

10
30
25
40
0

The 5th item was never set to anything, so A(5) returns a 0.

A mat statement can also refer to a range within an array, for example

PRINT MAT A(2:4)

would return

30
25
40

Arrays can be sorted, which changes the order of the items contained within the arrays. For example, to sort an array in ascending order:

AIDX(Mat A)

returns

0
10
25
30
40

Arrays can also have more than one dimension.

X(1,1)=5
X(1,2)=10
X(2,1)=15
X(2,2)=20

These are easiest to picture like a spread sheet with the two numbers identifying which cell a value is contained in (or like X and Y on a graph). Arrays can have up to 9 dimensions.

See Also