Berikut ini akan ditunjukkan cara melakukan transpose, penjumlahan, pengurangan, perkalian matriks, determinan dan invers dari matriks di SAS. Di sini kami memperkenalkan SAS / IML perangkat lunak melalui proc IML, prosedur yang memungkinkan pengguna untuk menulis pernyataan SAS untuk menampilkan vektor / matriks aljabar.
1. Transpose, Addition, Subtraction and Multiplication (Transpose, Penambahan, Pengurangan dan Perkalian) matriks
title 'Transpose of a matrix';
proc iml;
A={2 5, 7 10, 3 4};/*matrix A 3 x 2*/
B={4,7,10}; /* get a 3 1 vector B*/
AT=A`*A; /*Transpose of matrix A*/
BT=B`*A; /* Transpose of vector B*/
print A, AT, B, BT;
Run;
title 'Addition and Subtraction of matrices';
proc iml;
A={1 4, 2 5, 3 6};/*get a 3 2 matrix A*/
B={1 2, 2 3, 3 4};/*get a 3 2 matrix B*/
C=A+B;/*addition of matrices*/
D=A-B;/*subtraction of matrices*/
print A, B,C,D;
run;
title 'Multiplication of matrices';
proc iml;
A={2 7, 9 3};/*get a 2 2 matrix A*/
B={4 6, 5 8};/*get a 2 2 matrix B*/
C=4*A; /*multiplication of a matrix by a scalar*/
D=A*B;/*multiplication of a matrix by a matrix*/
print A, B, C, D;
run;
2. Determinant and Invers
title 'Determinant and Inverse of a matrix';
proc iml;
A={1 3 2 5, 1 2 5 3, 1 -1 2 2, 5 2 -1 4};/*get a 4 4 matrix A*/
Bdet=det(A);/*determinant of a matrix*/
Cinv=inv(A);/*inverse of a matrix*/
print A, Bdet, Cinv;
run;
Tidak ada komentar:
Posting Komentar