Matrix attributes, such as number of rows, number of columns, total number of elements, are accessible in several ways. All attributes are accessible through function calls, for example:
> a = rand(3,5); > show (a) name: a class: num type: real nr: 3 nc: 5 > size (a) 3 5 > class (a) num > type (a) real
Matrix attributes are also accessible via a shorthand notation:
> a.nr 3 > a.nc 5 > a.n 15 > a.class num > a.type real
Note that these matrix attributes are ``read-only''. In other
words: assignment to a.nr
is pointless. In fact it will
destroy the contents of a
and create a list with element
named nr
. If you wish to change a matrix attribute, you must
do so by changing the data in a
. For example: if you want to
make a
complex:
> a = a + zeros (size (a))*1i; > show(a) name: a class: num type: complex nr: 3 nc: 5
If you want to change the number of rows, or columns of a
:
> a = reshape (a, 1, 15); > show(a) name: a class: num type: complex nr: 1 nc: 15