下标 |
在A的行i和列j中的元素是被A(i,j)表示。例如,A(4,2)是在第四行和第二列的数字。例如我们的魔方,A(4,2)是15。因此计算在A的第四列中的和,键入 A(1,4) + A(2,4) + A(3,4) + A(4,4) 这会产生 ans = 但是求取一个单列的和不是很雅致的方式。 涉及到一个下带有下标的矩阵的元素这也很重要,A(k)。这通常参考行和列向量的方式。但是它也能应用到一个饱满的二维矩阵,在任意事件中队列是顾及作为一个长列向量的格式,其格式来源于原型矩阵的列。因此,例如我们的魔方,A(8)是其它方式指向到被存储在A(4,2)中的值15。 如果你尽力使用一个矩阵的元素外部的值,它是一个错误。 t = A(4,5) 索引超过矩阵维度。 在其他形式上,如果你存储一个值在一个矩阵的元素外部,尺寸增加到适应新形式。 X = A; X = |
Subscripts
The element in row i and column j of A is denoted by A(i,j). For example, A(4,2) is the number in the fourth row and second column. For our magic square, A(4,2) is 15. So to compute the sum of the elements in the fourth column of A, type
A(1,4) + A(2,4) + A(3,4) + A(4,4)
This produces
ans =
34
but is not the most elegant way of summing a single column.
It is also possible to refer to the elements of a matrix with a single subscript, A(k). This is the usual way of referencing row and column vectors. But it can also apply to a fully two-dimensional matrix, in which case the array is regarded as one long column vector formed from the columns of the original matrix. So, for our magic square, A(8) is another way of referring to the value 15 stored in A(4,2).
If you try to use the value of an element outside of the matrix, it is an error.
t = A(4,5)
Index exceeds matrix dimensions.
On the other hand, if you store a value in an element outside of the matrix, the size increases to accommodate the newcomer.
X = A;
X(4,5) = 17
X =
16 3 2 13 0
5 10 11 8 0
9 6 7 12 0
4 15 14 1 17