该帮助的版本不再更新,请参见https://www.jmp.com/support/help/zh-cn/15.2 获取最新的版本.


Use the subscript operator ([ ]) to pick out elements or submatrices from matrices. The Subscript() function is usually written as a bracket notation after the matrix to be subscripted, with arguments for rows and columns.
The expression A[i,j] extracts the element in row i, column j, returning a scalar number. The equivalent functional form is Subscript(A,i,j).
P = [1 2 3, 4 5 6, 7 8 9];
P[2, 3]; // returns 6
Subscript( P, 2, 3 ); // returns 6
A = [1 2, 3 4, 5 6];
test = A[3, 1];
Show( test );
P = [1 2 3, 4 5 6, 7 8 9];
P[[2 3],[1 3]]; // matrix subscripts
P[{2, 3},{1, 3}]; // list subscripts
Q = [2 4 6, 8 10 12, 14 16 18];
Q[8]; // same as Q[3,2]
Q = [2 4 6, 8 10 12, 14 16 18];
Q[{5, 7, 9}];
Q[[5 7 9]];
ii = [5 7 9];
ii = {5, 7, 9};
Subscript( Q, ii );
P = [1 2 3, 4 5 6, 7 8 9];
For( i = 1, i <= 3, i++,
For( j = 1, j <= 3, j++,
Show( P[i, j] )
P = [1 2 3, 4 5 6, 7 8 9];
P[0, 2];
P[0, [3, 2]];
P[3, 0];
P[[2, 3], 0];
P[0, 0];
P = [1 2 3, 4 5 6, 7 8 9];
P[2, 3] = 99;
Show( P );
P = [1 2 3, 4 5 6, 7 8 9];
P[[1 2], [2 3]] = [66 77, 88 99];
Show( P );
P = [1 2 3, 4 5 6, 7 8 9];
P[0, 2] = [11, 22, 33];
Show( P );
P = [1 2 3, 4 5 6, 7 8 9];
P[3, 0] = [100 102 104];
Show( P );
P = [1 2 3, 4 5 6, 7 8 9];
P[2, 0] = 99;
Show( P );
You can use operator assignments (such as +=) on matrices or subscripts of matrices. For example, the following statement adds 1 to the i - jth element of the matrix:
P = [1 2 3, 4 5 6, 7 8 9];
P[1, 1] += 1;
Show( P );
P[1, 1] += 1;
Show( P );
If you are working with a range of subscripts, use the Index() function or :: to create matrices of ranges.
T1 = 1 :: 3; // creates the vector [1 2 3]
T2 = 4 :: 6; // creates the vector [4 5 6]
T3 = 7 :: 9; // creates the vector [7 8 9]
T = T1 |/ T2 |/ T3; // concatenates the vectors into a single matrix
T[1 :: 3, 2 :: 3]; // refers to rows 1 through 3, columns 2 and 3
T[Index( 1, 3 ), Index( 2, 3 )]; // equivalent Index function