27.03.2013 Views

SPSS® 12.0 Command Syntax Reference

SPSS® 12.0 Command Syntax Reference

SPSS® 12.0 Command Syntax Reference

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

MATRIX—END MATRIX 919<br />

For example, if S is a scalar matrix, S = 2 , R is a row vector, R = 135 , C is a<br />

column vector, C =<br />

2<br />

3<br />

4<br />

, and A is a 5 × 5 matrix, A =<br />

11 12 13 14 15<br />

21 22 23 24 25<br />

31 32 33 34 35<br />

41 42 43 44 45<br />

51 52 53 54 55<br />

, then:<br />

R(S) = R(2) = {3}<br />

C(S) = C(2) = {3}<br />

• An integer index extracts an element from a vector matrix.<br />

• The distinction between a row and a column vector does not matter when an integer index<br />

is used to extract an element from it.<br />

A(2,3) = A(S,3) = {23}<br />

• Two integer indexes separated by a comma extract an element from a rectangular matrix.<br />

A(R,2)=A(1:5:2,2)={12; 32; 52}<br />

A(2,R)=A(2,1:5:2)={21, 23, 25}<br />

A(C,2)=A(2:4,2)= {22;32;42}<br />

A(2,C)=A(2,2:4)= {22,23,24}<br />

• An integer and a vector index separated by a comma extract a vector from a matrix.<br />

• The distinction between a row and a column vector does not matter when used as indexes<br />

in this way.<br />

A(2,:)=A(S,:) = {21, 22, 23, 24, 25}<br />

A(:,2) =A(:,S)= {12; 22; 32; 42; 52}<br />

• A colon by itself used as an index extracts an entire row or column vector from a matrix.<br />

A(R,C)=A(R,2:4)=A(1:5:2,C)=A(1:5:2,2:4)={12,13,14;32,33,34;52,53,54}<br />

A(C,R)=A(C,1:5:2)=A(2:4,R)=A(2:4,1:5:2)={21,23,25;31,33,35;41,43,45}<br />

• Two vector indexes separated by a comma extract a submatrix from a matrix.<br />

• The distinction between a row and a column vector does not matter when used as indexes<br />

in this way.<br />

Construction of a Matrix from Other Matrices<br />

You can use vector or rectangular matrices to construct a new matrix, separating row expressions<br />

by semicolons and components of row expressions by commas. If a column vector Vc has n elements<br />

and matrix M has the dimensions n× m,<br />

then {M, Vc} is an n × ( m + 1)<br />

matrix. Similarly,<br />

if the row vector Vr has m elements and M is the same, then {M; Vr} is an ( n + 1)<br />

×<br />

m<br />

matrix. In fact, you can paste together any number of matrices and vectors this way.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!